页面里有
<input name="main_1" class="Html_001_a3" type="text">
<input name="main_2" class="Html_001_a3" type="text">
<input name="main_N" class="Html_001_a3" type="text">
如何点击 按钮后给main_N的VALUE添加内容。
按钮是runat="server"的。所以必须在C#里写。
for (int i = 0; i < 20; i++)
{
if (Request.Form["main_" + i] != null)
{ //Response.Write["main_" + i] = //ds.Tables[0].Rows[0][n].ToString();}
}
上面是错误的。如何实现?
<input name="main_1" class="Html_001_a3" type="text">
<input name="main_2" class="Html_001_a3" type="text">
<input name="main_N" class="Html_001_a3" type="text">
如何点击 按钮后给main_N的VALUE添加内容。
按钮是runat="server"的。所以必须在C#里写。
for (int i = 0; i < 20; i++)
{
if (Request.Form["main_" + i] != null)
{ //Response.Write["main_" + i] = //ds.Tables[0].Rows[0][n].ToString();}
}
上面是错误的。如何实现?
for (int i = 1; i < 20; i++)
{
string sId = "main_" + i.ToString();
//Response.Write["main_" + i] = //ds.Tables[0].Rows[0][n].ToString();
ClientScript.RegisterStartupScript(this.GetType(), "t1", "<script>if(document.all['" + sId + "']==null){} else {document.all['" + sId + "'].value = 'a' ;)}</script>");
}
在后台写GetValue返回值.
//这里加上Value="<%=value%>",意识是从服务端取一个值在这里输出。然后在ASPX.CS文件里的BUTTON_CLICK事件里写下面代码
value = "Hello!"
需要注意的是,value 须在aspx.cs中声明为PUBLIC