validation message only show in val summary when ShowSummary=true when no js to execute on client

T

TS

i have a page where JS is enabled. I have validation controls that have
custom validators and don't have clientValidationFunctions. when a
validation error occurs, the page stops processing and returns. When i have
ShowSummary = true, the error messages appear in the validation summary on
the page. When i have ShowSummary = false and ShowMessageBox = true, the
error messages aren't displayed in a popup box, only the validation
control's text is displayed on the form ("*").

Why is this?

thanks
 
W

Walter Wang [MSFT]

Hi,

Thank you for your post.

ValidationSummary.ShowMessageBox was designed to pop up a dialog box to
show errors when client-side validation happens. Since the CustomValidator
does not have any client-side validation function, hence no client-side
validation happens when the button clicked.

You can workaround this by following code:

void ValidateBtn_OnClick(object sender, EventArgs e)
{
if (!Page.IsValid)
{
string msg = "Errors: \\n";
foreach(IValidator v in Validators)
{
if (!v.IsValid)
{
msg += v.ErrorMessage + "\\n";
}
}
ClientScript.RegisterStartupScript(this.GetType(), "error",
"javascript:alert('" + msg + "');", true);
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Ashu

hi,

I have a page with 4 textboxes. Two of them are mandatory fields,
whereas the other two have a condition as follows,

if one is entered a value, the other should also be entered a value.

how can i achieve with validation controls.

Any help would be really appreciated.

thanks,
Ashu.
 
T

TS

thanks Walter I see this situation.

Ashu, you'll have to create a customvalidator and handle that logic in it on
the server side and if you want the client side
 
W

Walter Wang [MSFT]

Thank you for your update and please let me know if you need more help on
this.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top