Click Event Not Fired

Last post 05-09-2008 10:27 AM by ramblor. 6 replies.

Sort Posts:

  • Click Event Not Fired

    05-09-2008, 9:24 AM
    • Loading...
    • denniscy
    • Joined on 08-15-2007, 1:22 PM
    • Posts 55

    Hi,

    I have a search user control added to different pages. The button on the control works for all pages except for one, which has the same master page with other pages and the same properties for the page object as the working pages.

    I have used web developer helper to see the differences between the rendered html for the control for working and not working pages.

     The only difference seems to be that the onclick event of the ImageButton has this entry:

    javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$searcher$search_btn", "", true, "", "", false, false))

    There is no entry at all for the onclick event for pages with working controls.I would be glad if someone can help.

    I know that this method is used by asp.net to cause post backs but I do not know how it is associated with the input tag in this case.

    Also, in the pages that the control is working, could someone enlighten me about how this event handler is called despite being associated with the event at the markup. 

     Control code:

    Front End

     ------------------------------

    <input class="text" runat="server" id="search_txt" value="Search here..t." />&nbsp;

    <asp:ImageButton runat="server" ID="search_btn" CssClass="searchbtn" ImageUrl="/public/img/round_button.png"

    AlternateText="search" Width="22px" Height="22px">

    Back End

    ------------------------------

    Protected Sub search_btn_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles search_btn.Click

    Thanks.

  • Re: Click Event Not Fired

    05-09-2008, 9:33 AM
    • Loading...
    • xanderer
    • Joined on 04-17-2008, 4:31 PM
    • Posts 36

     add the event to the button

     <asp:ImageButton runat="server" ID="search_btn" CssClass="searchbtn" ImageUrl="/public/img/round_button.png"

    AlternateText="search" Width="22px" Height="22px" OnClick="search_btn_Click">

  • Re: Click Event Not Fired

    05-09-2008, 9:53 AM
    • Loading...
    • denniscy
    • Joined on 08-15-2007, 1:22 PM
    • Posts 55

    Thank you for your response.

    That was the first thing I tried, but had no effect on the page where the button in the control is not working.

    For pages, where the control is already working, they somehow work without the event being associated with a handler on the mark up.

  • Re: Click Event Not Fired

    05-09-2008, 9:59 AM
    Answer
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 6:03 AM
    • Posts 552
    Is there any validation on the page that might be stopping the postback?
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
  • Re: Click Event Not Fired

    05-09-2008, 10:01 AM
    • Loading...
    • xanderer
    • Joined on 04-17-2008, 4:31 PM
    • Posts 36

    Sorry I should have read that better.  In the pages where the button is working, the event is called because of the ByVal e As System.Web.UI.ImageClickEventArgs. so if you add another image button to the page it would call that event because the Imageclickevent is fired when a image button is clicked.

  • Re: Click Event Not Fired

    05-09-2008, 10:24 AM
    • Loading...
    • denniscy
    • Joined on 08-15-2007, 1:22 PM
    • Posts 55

    Thank you for the solution.

     Adding

    CausesValidation="false"

    to the markup of the button solved my problem. For the note, there was no validation in the search control, the page using the control and the master page.

    But some of the controls included in the master page may have validation.

  • Re: Click Event Not Fired

    05-09-2008, 10:27 AM
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 6:03 AM
    • Posts 552

    Great, glad you got it sorted. I guessed it was that as in this line:

    javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$searcher$search_btn", "", true, "", "", false, false))

    the true parameter causes client-side validation on the page to be fired.

    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Page 1 of 1 (7 items)