0

I know I have a similar question but I selected a answer as correct before I actually tested it since technically they were correct I was trying to use .text.

I have html control and im trying to get the input value from the user however for some reason even though I have data when I debug that line it just shows ""

<input runat="server" id="Name" type="text" name="Name"/>

cmd.parameters.addwithvalue("@NAME", Name.value);

name.value never has a value no matter what I put in the input name control.

4

3 回答 3

2

删除引号:

cmd.parameters.addwithvalue("@name", name.value);

您实际上是在传递“name.value”而不是 value 属性。

于 2013-08-14T12:04:06.790 回答
1

尝试这个

<input runat="server" id="Name" type="text" name="Name"/>

cmd.Parameters.Add(new SqlParameter("@name", name.value));
于 2013-08-14T12:03:30.973 回答
0

试试看

<input runat="server" id="Name" type="text" name="Name"/>

cmd.Parameters.Add(new SqlParameter("@name", Request.Form["Name"]));
于 2013-08-14T14:36:32.987 回答