为什么用JS脚给文本框赋值后:页面会报错?
提示要设置为EnableEventValidation="false"
设置后,在服务器端取不到值?请问如何解决?
HTML页面中:function SetValue()
{
var sltModule = document.getElementById("ddlModule");
var index = sltModule.selectedIndex;
if(index > 0)
{
var text = sltModule.options[index].text;
var value = sltModule.options[index].value;
document.getElementById("txtModuleNo").vlaue = value;
document.getElementById("txtModuleName").vlaue = text;
}
}
<asp:DropDownList ID="ddlModule" runat="server" Width="100px" onchange="SelectModule()">
</asp:DropDownList>
<asp:TextBox ID="txtModuleNo" runat="server" Width="0px"></asp:TextBox>
<asp:TextBox ID="txtModuleName" runat="server" Width="0px"></asp:TextBox>C#服务器端读取文本框中的值:string moduleNo = this.txtModuleNo.Text;
提示要设置为EnableEventValidation="false"
设置后,在服务器端取不到值?请问如何解决?
HTML页面中:function SetValue()
{
var sltModule = document.getElementById("ddlModule");
var index = sltModule.selectedIndex;
if(index > 0)
{
var text = sltModule.options[index].text;
var value = sltModule.options[index].value;
document.getElementById("txtModuleNo").vlaue = value;
document.getElementById("txtModuleName").vlaue = text;
}
}
<asp:DropDownList ID="ddlModule" runat="server" Width="100px" onchange="SelectModule()">
</asp:DropDownList>
<asp:TextBox ID="txtModuleNo" runat="server" Width="0px"></asp:TextBox>
<asp:TextBox ID="txtModuleName" runat="server" Width="0px"></asp:TextBox>C#服务器端读取文本框中的值:string moduleNo = this.txtModuleNo.Text;
改成
getElementById("<%=ddlModule.ClientID%>");
别的也这样修改!!
只是用JS赋值,服务器端最值而已.
客户端不要把控件Disable掉,这样值也不会传回服务端。