c# - Using a validation summary to display label text -


i have taken on maintenance of site makes calls through wcf service. there validation summary displays in message box validators on client-side. have label fires if exceptions arise web service calls. after tweaking layout, label sits in inconvenient spot. want know if there way display label text in validation summary should exception fire in code behind.

any advice appreciated.

example in cs file:

bool resultuserexistence = register.checkuniquenessuserid(txtuserid.text);  if (resultuniquenessemail == null) {     continue through code... }  else {     lblexception.text = "please choose different user name. current user name registered."; } 

validation summary:

<asp:validationsummary id="valsummary"                     runat="server"                     headertext="please correct following error(s):"                     displaymode="list"                     forecolor="#ff9999"                     showmessagebox="true"                     showsummary="false" /> 

as notied in this answer create custom validator, , set message on that, make message show in validation summary.

bool resultuserexistence = register.checkuniquenessuserid(txtuserid.text);  if (resultuniquenessemail == null) {     continue through code... }  else {     var err new customvalidator()     err.validationgroup = "useruniqueness";     err.isvalid = false;     err.errormessage = "please choose different user name. current user name registered.";     page.validators.add(err);      } 

ideally factored out method reusability.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -