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

Discussion in 'ASP .Net Web Controls' started by TS, Jun 21, 2006.

  1. TS

    TS Guest

    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
    TS, Jun 21, 2006
    #1
    1. Advertising

  2. 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.
    Walter Wang [MSFT], Jun 22, 2006
    #2
    1. Advertising

  3. TS

    Ashu Guest

    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:
    > 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.
    Ashu, Jun 22, 2006
    #3
  4. TS

    TS Guest

    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]" <> wrote in message
    news:8HrfO%...
    > 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.
    >
    TS, Jun 23, 2006
    #4
  5. Thank you for your update and please let me know if you need more help on
    this.

    Have a nice day!

    Regards,
    Walter Wang (, 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.
    Walter Wang [MSFT], Jun 24, 2006
    #5
  6. TS

    Ashu Guest

    Thanks,

    I used the custom validator.

    thanks for the help.

    Ashu.

    TS wrote:
    > 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]" <> wrote in message
    > news:8HrfO%...
    > > 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.
    > >
    Ashu, Jul 6, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick Guio
    Replies:
    6
    Views:
    3,194
    chris
    Oct 20, 2004
  2. Holger
    Replies:
    11
    Views:
    547
    Gabriel Genellina
    Feb 12, 2007
  3. bdb112
    Replies:
    45
    Views:
    1,338
    jazbees
    Apr 29, 2009
  4. Michael Neumann

    "val.dup rescue val" sloooow

    Michael Neumann, Oct 27, 2004, in forum: Ruby
    Replies:
    2
    Views:
    132
    Michael Neumann
    Oct 27, 2004
  5. Anita Anita
    Replies:
    2
    Views:
    103
    Gary Wright
    Jan 6, 2009
Loading...

Share This Page