在asp.net中获取HTML输入框的值 [英] Get Value of HTML Input box in asp.net
本文介绍了在asp.net中获取HTML输入框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在.aspx页面中有一个HTML文本框(不是TextBox服务器控件)。用ASP.NET获取HTML文本框的值而不将元素声明为runat =server是否可能
?如何从服务器上的C#获取HTML元素的值?
Hi
I have a HTML text box (NOT a TextBox server control) in a .aspx page. Is it possible
with ASP.NET to get the value of the HTML text box without declare the element as runat="server"? How can I get the value of an HTML element from C# on the server?
推荐答案
您可以使用Request对象访问控件的值。请求[TextBoxID]
应该在文本框中显示文本。
其他选项是 - 存储TextBox的隐藏字段onblur
中的TextBox值。然后在服务器上访问这个隐藏的字段值。
希望这会有所帮助!
修改Albin Abel建议的答案。[/ Edit]
You can access the value of the control using Request object.Request["TextBoxID"]
should give you the text in the textbox.
Other option is - store the TextBox value in a Hidden Fieldonblur
of the TextBox. Then access this hidden field value on the server.
Hope this helps!
Modified the answer as suggested by Albin Abel.[/Edit]
我在.aspx页面中有一个HTML文本框(不是TextBox服务器控件)。有可能=是的,可能的。在这种情况下,与经典asp没有什么不同。如果您没有runat =server
,那么您可以通过旧学校方式访问它。
说你有这个< input type =textid =text1name =text1/>
然后从服务器端使用请求[text1]
。
祝你好运
I have a HTML text box (NOT a TextBox server control) in a .aspx page. Is it possible= Yes, possible. Nothing different from classical asp in this case. If you don't haverunat="server"
then you can access it through the old school way.
say you have this<input type="text" id="text1" name="text1" />
then from server side useRequest["text1"]
.
Good luck
首先在javascript中获取文本的值
然后将其作为参数发送到服务器端方法
无论你想要什么操作,你可以做他们的
它会运作良好。
First get the value of the text in javascript
Then send it as a parameter to the serverside method
whatever operations you want, you can do their
It will work well.
这篇关于在asp.net中获取HTML输入框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文