这么为什么无法获得表单数据
这样为什么无法获得表单数据
<!--javascript部分>
<script type="text/javascript">
function OnUpLoad() {
var Uname = document.getElementById("ItId").value;
var Una = document.getElementById("ItName").value;
var Un = document.getElementById("StreentAddress").value;
alert(Uname+Una+Un); //正常的
document.getElementById("F1").submit();
}
</script>
<!--html部分-->
<form id="F1" action="Handler.ashx" method="get">
<table>
<tbody>
<tr><td><label>Id</label><td>
<td><input type="text" id="ItId"/></td>
</tr>
<tr>
<td><label>Name:</label></td>
<td> <input type="text" id="ItName" /></td>
</tr>
<tr>
<td>Address:</td>
<td> <input type="text" id="StreentAddress" /></td>
</tr>
<tr>
<td>
<input type="button" value="提交" onclick="OnUpLoad()" id="But1"/>
<td>
</tr>
</tbody>
</table>
</form>
int er = 0;
string strId = context.Request.Form["ItId"]; //这里就没有数据的了
string strName = context.Request.Form["ItName"];
string strStreentAddress = context.Request.Form["StreentAddress"];
int id = Convert.ToInt32(strId);
using (SqlConnection SqlC = new SqlConnection("Data Source=.;Initial Catalog=db_2008;Integrated Security=True"))
{
SqlC.Open();
SqlCommand Sc = SqlC.CreateCommand();
Sc.CommandText = "INSERT INTO A values(@id,@name,@Address)";
SqlParameter[] SP = { new SqlParameter("@id", id), new SqlParameter("@name", strName), new SqlParameter("@Address", strStreentAddress) };
Sc.Parameters.AddRange(SP);
er = Sc.ExecuteNonQuery();
SqlC.Close();