Home All Groups Group Topic Archive Search About

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

Author
21 Jun 2006 10:38 PM
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

Author
22 Jun 2006 11:32 AM
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.
Author
22 Jun 2006 1:20 PM
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.


Walter Wang [MSFT] wrote:
Show quoteHide quote
> 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.
Author
23 Jun 2006 3:51 PM
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

Show quoteHide quote
"Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
news:8HrfO%23elGHA.5184@TK2MSFTNGXA01.phx.gbl...
> 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.
>
Author
24 Jun 2006 4:59 AM
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 (waw***@online.microsoft.com, 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.
Author
6 Jul 2006 9:08 PM
Ashu
Thanks,

I used the custom validator.

thanks for the help.

Ashu.

TS wrote:
Show quoteHide quote
> 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
>
> "Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
> news:8HrfO%23elGHA.5184@TK2MSFTNGXA01.phx.gbl...
> > 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.
> >