简单问题
在(.cs)后面的代码中有
string error="11000114S";
在ASP (.aspx)中有:
<asp:TextBox ID="text" runat="server" EnableViewState="false" AutoPostBack="false"/>
<asp:RequiredFieldValidator id="textValidator" runat="server" controlToValidate="text"
errormessage=(our string error="11000114S")>
那么如何做到这一点,从cs->保存的错误列表分配值到html ?
只需将此添加到.cs中即可。如果我没理解错的话
string error="11000114S";
textValidator.ErrorMessage = error ; // or what ever you want
应该这样做
protected string error="11000114S";
<asp:TextBox ID="text" runat="server" EnableViewState="false" AutoPostBack="false"/>
<asp:RequiredFieldValidator id="textValidator" runat="server" controlToValidate="text"
errormessage='<%# error %>'>
您可以动态地将错误消息分配给代码后面的验证器。例如:
this.textValidator.ErrorMesssage = error;