Is there a way to display the error message once the foucs has moved from the checkboxlist control to the next item on the web page? If so, can you explain how this would occur and point me to a reference that would explain this process?
I have one additional question that is once the OnServerValidate event is fired, the error message does not display. The display occurs once I have code in the 'submiton event' that says if (!Page.IsPostBack) return; I would think once the OnServerValidate event finishes executing, I error message should be displayed. The error message should not wait until the logic in the submit button fires. Thus can you tell me if this is ok and why? if this is not ok, can you tell me why not and possibly point me to a reference to solve this issue?
The following is the code I am referring to:
EnableClientScript="False"
ErrorMessage="You must select at least one item.">
public void ValidateNumber(Object source, ServerValidateEventArgs args)
{
args.IsValid = false;
for (int i = 0; i < ChkBoxLstPlan.Items.Count; i++)
{
if (ChkBoxLstPlan.Items[i].Selected)
{
args.IsValid = true;
}
}
}
protected void submitbutton(object sender, EventArgs e)
{
if (!Page.IsPostBack)
return;
}
Javeed M ShaikhPosted Oct 28, 2011, 4:16 PM
Since the function called from CustomValidator is server side and the button event is also server side they both will fire one after teh other on the server as both the events has been raised. I would like you to use Page.IsValid in your submit button click to check of the validation is all ok on the page.