获得codebehind C#从输入HTML值 [英] Get value from input html in codebehind c#
问题描述
我做了一些研究,发现我怎么能读取输入HTML文本框的值。
I did some research and found out how I can read a value from the input html textbox.
这工作得很好,我,但一旦它不起作用。
This worked fine for me, but at once it doesn't work.
这是我的code,它的输入HTML返回null
This is my code, it input html returns null
<input type="text" name="inpNickname" placeholder="Nickname" data-placement="right" data-toggle="tooltip" title="Nickname" id="txtNickname" runat="server"/>
<input type="text" name="inpPassword" placeholder="Password" data-placement="right" data-toggle="tooltip" title="Password" id="txtPassword" runat="server"/>
string Nickname = Request.Form["inpNickname"];
string Password = Request.Form["inpPassword"];
如果我改变的Request.Form []将ID的,它仍然无法正常工作。
If I change the Request.Form[] to the ID's, it still doesn't work.
推荐答案
由于它是运行在服务器端...
Since it is running at the server...
txtNickname.Value
和 txtPassword.Value
会给你你所需要的。
txtNickname.Value
and txtPassword.Value
will give you what you need.
当您指定 =服务器
你基本上是给一个属性到codebehind类。所以,你可以访问属性,并将其直接的属性。
When you specify runat="server"
you are essentially giving a property to your codebehind class. So you can access that property and it's properties directly.
这篇关于获得codebehind C#从输入HTML值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!