Reputation: 54
simple question
in code behind(.cs) we have
string error="11000114S";
in ASP (.aspx) we have:
<asp:TextBox ID="text" runat="server" EnableViewState="false" AutoPostBack="false"/>
<asp:RequiredFieldValidator id="textValidator" runat="server" controlToValidate="text"
errormessage=(our string error="11000114S")>
So how to do this, assign value from cs-> saved error list to html ?
Upvotes: 0
Views: 395
Reputation: 8726
You can assign error messages dynamically to your validators in your code behind. I.e.:
this.textValidator.ErrorMesssage = error;
Upvotes: 0
Reputation: 1755
this should do
protected string error="11000114S";
<asp:TextBox ID="text" runat="server" EnableViewState="false" AutoPostBack="false"/>
<asp:RequiredFieldValidator id="textValidator" runat="server" controlToValidate="text"
errormessage='<%# error %>'>
Upvotes: 0
Reputation: 30244
It is as simple as adding this to your .cs .. if I understand you correctly
string error="11000114S";
textValidator.ErrorMessage = error ; // or what ever you want
Upvotes: 2