OnClick not being called when there are validation errors

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: OnClick not being called when there are validation errors

    Do you happen to have smartNavigation set to true by any chance? if so, turn
    it off and try it.

    fadi

    "Dano" <dtemple7502@rogers.com> wrote in message
    news:dsDKa.18605$H9q1.13820@news04.bloor.is.net.ca ble.rogers.com...
    > Hi everyone,
    >
    > I am having some problems with the validator controls and the button
    > controls on_click event.
    >
    > Suppose you have a textbox where you enter in a name. Then you have a Save
    > and a Cancel button. The Cancel Button redirects the user to the main
    page.
    > Now if you have a Required Field Validator on the textbox for the name,
    then
    > when you hit the save and the field is empty, you get client side
    > validation, and the corresponding error messages posted on the
    > asp:ValidationSummary control. BUT, once this happens and you have errors
    > actually listed on the page, my buttons no longer work. I stepped through
    > the code, and in this case when a button is clicked, the server On_Load
    sub
    > is run, but once this is run the button's On_Click sub (which was working
    > fine before), is no longer run. This happens even when the
    CausesValidation
    > is set to false on the Cancel Button.
    >
    > Here is the code
    >
    > <asp:ValidationSummary ID="valSummary" Runat="server" HeaderText="The
    > following errors were found:" showsummary="true" DisplayMode="List" />
    >
    >
    >
    > <asp:RequiredFieldValidator ID="valName" Runat="server"
    > ControlToValidate="txtName" ErrorMessage="* You must enter a name"
    > Display="Dynamic">*</asp:RequiredFieldValidator><asp:textbox ID="txtName"
    > Runat="server" />
    >
    >
    >
    > <asp:Button ID='btnSave' Text="Save" CausesValidation="True"
    runat="server"
    > OnClick="saveInfo"></asp:Button>
    >
    >
    >
    >
    > <asp:Button id="btnReturn" Text="Cancel" runat="server"
    > CausesValidation="False" OnClick="goToMainPage"></asp:Button>
    >
    > </Code>
    >
    >
    > The actual content of the OnClick sub itself is moot, since in the
    > problematic case, it is no longer called. In my case it is a single
    redirect
    > line. Does anyone know why my OnClick routines no longer work when there
    are
    > validation errors, even though CausesValidation is set to false?
    >
    > Dano
    >
    >

    fadi Guest

  2. Similar Questions and Discussions

    1. #39868 [NEW]: Destructor is called allthought constructor is never called
      From: jb at ez dot no Operating system: Kubuntu 6.10 PHP version: 5.2.0 PHP Bug Type: *General Issues Bug description: ...
    2. #39678 [Opn->Bgs]: __set and __get not called where a class attribute is called statically
      ID: 39678 Updated by: tony2001@php.net Reported By: denis at edistar dot com -Status: Open +Status: ...
    3. #39678 [NEW]: __set and __get not called where a class attribute is called statically
      From: denis at edistar dot com Operating system: Linux PHP version: 5.2.0 PHP Bug Type: Scripting Engine problem Bug...
    4. xhtml Validation Errors
      Hello. I am just learning to update html to xhtml and had a few validation errors I wondered if you could help me with. The first one says:...
    5. validation summary doesnt display when there's client-side validation
      I have a custom validator that validates a numeric field, txtField, that allows for thousand separators. I also placed a validation summary so...
  3. #2

    Default Re: OnClick not being called when there are validation errors

    I do indeed have smartNavigation on and you were absolutely right! Turning
    it off made the page behave properly, how did you know?

    So what exactly was happening? And is there anyway I can get
    smartNavigation and these validator controls to play nice together? Yeah, I
    know, I'm a picky guy ...

    Thanks for the info though!

    Dano


    "fadi" <fadiz@nospam.com> wrote in message
    news:#9G1B4$ODHA.3192@TK2MSFTNGP10.phx.gbl...
    > Do you happen to have smartNavigation set to true by any chance? if so,
    turn
    > it off and try it.
    >
    > fadi
    >
    > "Dano" <dtemple7502@rogers.com> wrote in message
    > news:dsDKa.18605$H9q1.13820@news04.bloor.is.net.ca ble.rogers.com...
    > > Hi everyone,
    > >
    > > I am having some problems with the validator controls and the button
    > > controls on_click event.
    > >
    > > Suppose you have a textbox where you enter in a name. Then you have a
    Save
    > > and a Cancel button. The Cancel Button redirects the user to the main
    > page.
    > > Now if you have a Required Field Validator on the textbox for the name,
    > then
    > > when you hit the save and the field is empty, you get client side
    > > validation, and the corresponding error messages posted on the
    > > asp:ValidationSummary control. BUT, once this happens and you have
    errors
    > > actually listed on the page, my buttons no longer work. I stepped
    through
    > > the code, and in this case when a button is clicked, the server On_Load
    > sub
    > > is run, but once this is run the button's On_Click sub (which was
    working
    > > fine before), is no longer run. This happens even when the
    > CausesValidation
    > > is set to false on the Cancel Button.
    > >
    > > Here is the code
    > >
    > > <asp:ValidationSummary ID="valSummary" Runat="server" HeaderText="The
    > > following errors were found:" showsummary="true" DisplayMode="List" />
    > >
    > >
    > >
    > > <asp:RequiredFieldValidator ID="valName" Runat="server"
    > > ControlToValidate="txtName" ErrorMessage="* You must enter a name"
    > > Display="Dynamic">*</asp:RequiredFieldValidator><asp:textbox
    ID="txtName"
    > > Runat="server" />
    > >
    > >
    > >
    > > <asp:Button ID='btnSave' Text="Save" CausesValidation="True"
    > runat="server"
    > > OnClick="saveInfo"></asp:Button>
    > >
    > >
    > >
    > >
    > > <asp:Button id="btnReturn" Text="Cancel" runat="server"
    > > CausesValidation="False" OnClick="goToMainPage"></asp:Button>
    > >
    > > </Code>
    > >
    > >
    > > The actual content of the OnClick sub itself is moot, since in the
    > > problematic case, it is no longer called. In my case it is a single
    > redirect
    > > line. Does anyone know why my OnClick routines no longer work when there
    > are
    > > validation errors, even though CausesValidation is set to false?
    > >
    > > Dano
    > >
    > >
    >
    >

    Dano Guest

  4. #3

    Default Re: OnClick not being called when there are validation errors

    I know because we ran into that problem on a project. What happens is that
    smartNavigation creates an IFRAME spanning the page and loads the page
    inside it. Looks like there is a bug where javascript and Response.Redirect
    may not function right at times after postbacks due to the IFRAME problem.
    Not sure what is a good workaround for it, I only use smartNavigation now
    for modal popup windows.

    Fadi

    "Dano" <dtemple7502@rogers.com> wrote in message
    news:VIKKa.39693$bRt.28216@news01.bloor.is.net.cab le.rogers.com...
    > I do indeed have smartNavigation on and you were absolutely right! Turning
    > it off made the page behave properly, how did you know?
    >
    > So what exactly was happening? And is there anyway I can get
    > smartNavigation and these validator controls to play nice together? Yeah,
    I
    > know, I'm a picky guy ...
    >
    > Thanks for the info though!
    >
    > Dano
    >
    >
    > "fadi" <fadiz@nospam.com> wrote in message
    > news:#9G1B4$ODHA.3192@TK2MSFTNGP10.phx.gbl...
    > > Do you happen to have smartNavigation set to true by any chance? if so,
    > turn
    > > it off and try it.
    > >
    > > fadi
    > >
    > > "Dano" <dtemple7502@rogers.com> wrote in message
    > > news:dsDKa.18605$H9q1.13820@news04.bloor.is.net.ca ble.rogers.com...
    > > > Hi everyone,
    > > >
    > > > I am having some problems with the validator controls and the button
    > > > controls on_click event.
    > > >
    > > > Suppose you have a textbox where you enter in a name. Then you have a
    > Save
    > > > and a Cancel button. The Cancel Button redirects the user to the main
    > > page.
    > > > Now if you have a Required Field Validator on the textbox for the
    name,
    > > then
    > > > when you hit the save and the field is empty, you get client side
    > > > validation, and the corresponding error messages posted on the
    > > > asp:ValidationSummary control. BUT, once this happens and you have
    > errors
    > > > actually listed on the page, my buttons no longer work. I stepped
    > through
    > > > the code, and in this case when a button is clicked, the server
    On_Load
    > > sub
    > > > is run, but once this is run the button's On_Click sub (which was
    > working
    > > > fine before), is no longer run. This happens even when the
    > > CausesValidation
    > > > is set to false on the Cancel Button.
    > > >
    > > > Here is the code
    > > >
    > > > <asp:ValidationSummary ID="valSummary" Runat="server" HeaderText="The
    > > > following errors were found:" showsummary="true" DisplayMode="List" />
    > > >
    > > >
    > > >
    > > > <asp:RequiredFieldValidator ID="valName" Runat="server"
    > > > ControlToValidate="txtName" ErrorMessage="* You must enter a name"
    > > > Display="Dynamic">*</asp:RequiredFieldValidator><asp:textbox
    > ID="txtName"
    > > > Runat="server" />
    > > >
    > > >
    > > >
    > > > <asp:Button ID='btnSave' Text="Save" CausesValidation="True"
    > > runat="server"
    > > > OnClick="saveInfo"></asp:Button>
    > > >
    > > >
    > > >
    > > >
    > > > <asp:Button id="btnReturn" Text="Cancel" runat="server"
    > > > CausesValidation="False" OnClick="goToMainPage"></asp:Button>
    > > >
    > > > </Code>
    > > >
    > > >
    > > > The actual content of the OnClick sub itself is moot, since in the
    > > > problematic case, it is no longer called. In my case it is a single
    > > redirect
    > > > line. Does anyone know why my OnClick routines no longer work when
    there
    > > are
    > > > validation errors, even though CausesValidation is set to false?
    > > >
    > > > Dano
    > > >
    > > >
    > >
    > >
    >
    >

    fadi Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139