ASP.Net 2.0 Button Event not Firing

Last post 03-22-2007 2:38 PM by mwilk4905. 5 replies.

Sort Posts:

  • ASP.Net 2.0 Button Event not Firing

    03-16-2007, 2:06 PM
    • Loading...
    • mwilk4905
    • Joined on 03-06-2007, 12:14 PM
    • Posts 9

    I currently have a page that I've been developing and testing in IE 6 and Firefox. I just recently update to IE 7 and now the button event doesn't fire.

     Below is the ASP.Net declaration for the button:

     <asp:TableCell><asp:Button ID="btnAdd" Text="Add" OnClick="btnAdd_Click" runat="server" ValidationGroup="InputGroup" /></asp:TableCell>

    It works fine in Firefox. It does reside inside an ajax update panle, but I've tried removing the panel and there is no postback when the button is clicked. The site is currently being ran locally from my machine.

    Has anyone had similar problem to this?

  • Re: ASP.Net 2.0 Button Event not Firing

    03-16-2007, 3:07 PM
    • Loading...
    • vivek_iit
    • Joined on 06-18-2006, 6:13 PM
    • New Delhi
    • Posts 3,072
    • TrustedFriends-MVPs

    Do you see any JavaScript error messages in the browser when you try to click that button? Try placing a another button on the same page to see if that works or try a new form. If this does not help create a simple new form with only one button and see if it works fine, then check the HTML of the previous page to see if there any controls which submit by default and have used HTML "submit" keywords as IDs.

    Hope this helps,

    Vivek 

    MVP, ASP.NET || My Website || Blog || Articles

    Please mark the most helpful reply/replies as "Answer".
  • Re: ASP.Net 2.0 Button Event not Firing

    03-16-2007, 6:00 PM
    • Loading...
    • mwilk4905
    • Joined on 03-06-2007, 12:14 PM
    • Posts 9

    I've creating a new website with the button and it works fine and I also added ajax update panels and they work fine too. It's just this one page that the OnClick code isn't get called. I've checked the source and there is code there for the Onclick for the button and no javascript errors appear. Below is a copy of the scriptmanager declaration and the updatePanel that contains this button that isn't working:

      

      
    

    <asp:ScriptManager ID="ajaxScriptManager" runat="server" EnablePartialRendering="true" />

     
     <
    asp:UpdatePanel ID="upDocuments" ChildrenAsTriggers="true" runat="server" UpdateMode="Conditional">

    <ContentTemplate>

    <asp:Table ID="tblDocuments" runat="server">

    <asp:TableRow Height="40px" />

    <asp:TableHeaderRow ID="trHeader" runat="server">

    <asp:TableHeaderCell runat="server" Text="DocumentType" HorizontalAlign="left" />

    <asp:TableHeaderCell runat="server" Text="Start Page" HorizontalAlign="center" />

    <asp:TableHeaderCell runat="server" Text="End Page" HorizontalAlign="center" />

    </asp:TableHeaderRow>

    <asp:TableRow ID="trAdd" runat="server">

    <asp:TableCell><asp:DropDownList ID="ddlDocumentType" runat="server" ValidationGroup="InputGroup" /></asp:TableCell>

    <asp:TableCell HorizontalAlign="center"><asp:TextBox ID="txtStartPage" Width="30" MaxLength="2" runat="server" ValidationGroup="InputGroup" /></asp:TableCell>

    <asp:TableCell HorizontalAlign="center"><asp:TextBox ID="txtEndPage" Width="30" MaxLength="2" runat="server" ValidationGroup="InputGroup" /></asp:TableCell>

    <asp:TableCell><asp:Button ID="btnAdd" CssClass="submitButton" Text="Add" OnClick="btnAdd_Click" runat="server" ValidationGroup="InputGroup" /></asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <asp:TableCell HorizontalAlign="center" ColumnSpan="4">

    <asp:RequiredFieldValidator ID="rfvStartPage" runat="server" ControlToValidate="txtStartPage" ValidationGroup="InputGroup" ErrorMessage="You must enter a start page." />

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <asp:TableCell HorizontalAlign="center" ColumnSpan="4">

    <asp:RequiredFieldValidator ID="rfvEndPage" runat="server" ControlToValidate="txtEndPage" ValidationGroup="InputGroup" ErrorMessage="You must enter an end page." />

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <asp:TableCell HorizontalAlign="center" ColumnSpan="4">

    <asp:CompareValidator ID="cvDocumentType" runat="server" ControlToValidate="ddlDocumentType" ValidationGroup="InputGroup" Operator="GreaterThan" ValueToCompare="0" ErrorMessage="You must select a document type." />

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <asp:TableCell HorizontalAlign="center" ColumnSpan="4">

    <asp:CompareValidator ID="cvPageCompare" runat="server" ControlToCompare="txtStartPage" ValidationGroup="InputGroup" ControlToValidate="txtEndPage" Operator="GreaterThanEqual" Type="integer" ErrorMessage="End page had to be greater than or equal the start page." />

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow>

    <asp:TableCell HorizontalAlign="center" ColumnSpan="4">

    <asp:UpdatePanel ID="uError" runat="server" UpdateMode="conditional">

    <ContentTemplate>

    <asp:Label ID="lblError" runat="server" ForeColor="red" />

    </ContentTemplate>

    </asp:UpdatePanel>

    </asp:TableCell>

    </asp:TableRow>

    <asp:TableRow Height="20px" />

    <asp:TableHeaderRow BorderWidth="1" ID="trAddedHeader" runat="server" CssClass="blackHeader">

    <asp:TableHeaderCell HorizontalAlign="center" Text="Documents List" ColumnSpan="4" />

    </asp:TableHeaderRow>

    <asp:TableHeaderRow ID="trColumnRow" Visible="false" runat="server">

    <asp:TableHeaderCell Text="Document Type" HorizontalAlign="center" runat="server" />

    <asp:TableHeaderCell Text="Start Page" HorizontalAlign="center" runat="server" />

    <asp:TableHeaderCell Text="End Page" HorizontalAlign="center" runat="server" />

    </asp:TableHeaderRow>

    <asp:TableRow BorderWidth="1" CssClass="normalText" ID="trNoDocuments">

    <asp:TableCell ColumnSpan="4" Text="No Documents" Font-Bold="true" HorizontalAlign="center" />

    </asp:TableRow>

    </asp:Table>

    </ContentTemplate>

    </asp:UpdatePanel>

     

    I've tried debbuging the page and when I click on the Add button, nothing happens. There is no postback at all.

  • Re: ASP.Net 2.0 Button Event not Firing

    03-18-2007, 1:37 AM
    • Loading...
    • vivek_iit
    • Joined on 06-18-2006, 6:13 PM
    • New Delhi
    • Posts 3,072
    • TrustedFriends-MVPs

    Try placing another button on this form and see if that works. Also is there any other control on this form that is "submitting" the form (causing a postback)?

    You can also check the generated HTML (View Source) and see if there is anything "fishy".

    Hope this helps,

    Vivek

    MVP, ASP.NET || My Website || Blog || Articles

    Please mark the most helpful reply/replies as "Answer".
  • Re: ASP.Net 2.0 Button Event not Firing

    03-22-2007, 2:37 PM
    • Loading...
    • mwilk4905
    • Joined on 03-06-2007, 12:14 PM
    • Posts 9
    I got the problem resolved. I created a new page an reconstructed the page I was working on but add a piece at a time and found that a form take was causing the problem. I just removed it and it works fine now. Thanks for your input.
  • Re: ASP.Net 2.0 Button Event not Firing

    03-22-2007, 2:38 PM
    Answer
    • Loading...
    • mwilk4905
    • Joined on 03-06-2007, 12:14 PM
    • Posts 9
    I got the problem resolved. I created a new page an reconstructed the page I was working on but add a piece at a time and found that a form tag was causing the problem. I just removed it and it works fine now. Thanks for your input.
Page 1 of 1 (6 items)
Microsoft Communities
Page view counter