Button Click event not getting called

Discussion in 'ASP .Net' started by SAL, Nov 20, 2008.

  1. SAL

    SAL Guest

    I'm working, basically my first, AJAX page and am having a few problems.
    One is that the Click event for a button I have in UpdatePanel1 is not
    getting called. I've tried with the button both inside and outside of the
    updatepanel and the event doesn't get called either way. What might I be
    missing here?

    Incidently, something else, kind of weird, is happening when the button is
    clicked, a required field validator control in a detailsview that I have on
    the page displays it's text, which in this case is just an astrix.

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
    <asp:GridView ID="gvStormDetail"
    <asp:CommandField ShowDeleteButton="True" />
    <asp:HyperLink ID="hlMap" runat="server"
    <asp:BoundField DataField="StormValueID"
    HeaderText="StormValueID" InsertVisible="False"
    ReadOnly="True" SortExpression="StormValueID"
    Visible="False" />
    <asp:BoundField DataField="StormAssetType"
    HeaderText="Asset Category" SortExpression="StormAssetType" >
    <ItemStyle HorizontalAlign="Center" />
    <asp:BoundField DataField="StormAssetTypeID"
    HeaderText="StormAssetTypeID" SortExpression="StormAssetTypeID"
    Visible="False" />
    <asp:BoundField DataField="StormAssetName"
    HeaderText="Storm Asset Name" SortExpression="StormAssetName" >
    <ItemStyle HorizontalAlign="Center" />
    <asp:BoundField DataField="StmFacilityClkID"
    HeaderText="StmFacilityClkID" SortExpression="StmFacilityClkID" >
    <ItemStyle HorizontalAlign="Center" />
    <asp:TemplateField HeaderText="Description"
    <asp:TextBox ID="TextBox2" runat="server"
    Text='<%# Bind("Description") %>'></asp:TextBox>
    <asp:Label ID="lblDescription" runat="server"
    EnableViewState="False" Height="24px"
    Text='<%# Bind("Description") %>'
    <ItemStyle HorizontalAlign="Center" />
    <asp:TemplateField HeaderText="Estimated Value"
    <asp:TextBox ID="TextBox1" runat="server"
    Text='<%# Bind("EstValue") %>'></asp:TextBox>
    <asp:Label ID="lblEstValue" runat="server"
    Text='<%# Bind("EstValue", "{0:C0}") %>'></asp:Label>
    <asp:TextBox ID="txtEstValue" runat="server"
    EnableViewState="False" Text='<%# Bind("EstValue", "{0:C0}") %>'
    Visible="False" Width="96px"></asp:TextBox>
    <ItemStyle HorizontalAlign="Right" />
    <asp:BoundField DataField="CntyAssetID"
    HeaderText="CntyAssetID" SortExpression="CntyAssetID"
    Visible="False" />
    <asp:BoundField DataField="ModUser" HeaderText="ModUser"
    <ItemStyle HorizontalAlign="Center" />
    <asp:BoundField DataField="ModDate"
    DataFormatString="{0:MM/dd/yyyy}" HeaderText="ModDate"
    HtmlEncode="False" SortExpression="ModDate">
    <ItemStyle HorizontalAlign="Center" />
    <br />
    <asp:ObjectDataSource ID="dsStormDetail" runat="server"
    <asp:SessionParameter Name="id"
    SessionField="cntyAssetId" Type="Int32" />
    <asp:parameter Name="stormValueId" Type="Int32" />
    <br />
    <asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
    Text="Update All" OnClick="btnUpdate_Click"/>
    <br />
    <asp:AsyncPostBackTrigger ControlID="dvStormInsert"
    EventName="ItemInserting" />
    SAL, Nov 20, 2008
    1. Advertisements

  2. SAL

    bruce barker Guest

    an update panel will not postback if validation has an error.

    -- bruce (sqlwork.com)
    bruce barker, Nov 20, 2008
    1. Advertisements

  3. SAL

    SAL Guest

    That detailsView is in another updatepanel though Bruce. I have two
    updatepanels on the page. Updatepanel1 has a Gridview and a button called
    Updatepanel2 has a detailsview in it. That's where the requiredfield
    validator is. Why in the world would it ...
    Oh, is it because I have the UpdateMode in Updatepanel1 set to always? If
    it's not set to always, it doesn't update when a new record is added via the
    detailsview in Updatepanel2...
    That can't be it because I've put the btnUpdate both inside and outside of

    Is this making any sense???

    SAL, Nov 20, 2008
  4. Hi,

    The validation will still stop the postback even the Validation control and
    the Button control are put in different UpdatePanels.

    To see if it's caused by the client side validation you can try to set
    CausesValidation="false" to test:

    <asp:Button ID="btnUpdate" runat="server" EnableViewState="False"
    Text="Update All" OnClick="btnUpdate_Click"

    Can the Click event handler get called in this way?

    Allen Chen
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:

    Get notification to my posts through email? Please refer to

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Allen Chen [MSFT], Nov 21, 2008
  5. SAL

    SAL Guest

    That did the trick Allen thanks.
    Appreciate the help once again....

    SAL, Nov 21, 2008
  6. You're welcome.

    Have a nice day!

    Allen Chen
    Microsoft Online Community Support
    Allen Chen [MSFT], Nov 24, 2008
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.