views:

379

answers:

2

I've a simple UpdatePanel and a button outside of it. I've introduced the button as an AsyncPostBackTrigger in the UpdatePanel. UpdatePanel itself works fine but the button does not. Whenever the button is clicked, its click handler does not run just like the button is not clicked at all!

Why the button is not working and how can it be fixed?


UPDATE: here is the markup:

            <asp:UpdatePanel ID="upGridView" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:GridView ID="grdList" SkinID="SimpleGridView" DataKeyNames="Key" runat="server"
                    AllowPaging="True" PageSize="15" AutoGenerateColumns="False" Caption="<%$ Resources: CommonResources, grdListCaption %>"
                    EmptyDataText="<%$ Resources: CommonResources, grdListEmptyDataText %>" OnRowEditing="grdList_RowEditing"
                    OnPageIndexChanging="grdList_PageIndexChanging" OnRowCreated="grdList_RowCreated">
                    <Columns>

                    </Columns>
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnNew" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnForward" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>

        <asp:Button ID="btnDelete" runat="server" SkinID="Button" Text="<%$ Resources: CommonResources, btnDelete %>"
            OnClick="btnDelete_Click" />
        <asp:Button ID="btnNew" runat="server" SkinID="Button" Text="<%$ Resources: CommonResources, btnNew %>"
            OnClick="btnNew_Click" />
        <asp:Button ID="btnForward" runat="server" SkinID="Button" meta:resourcekey="btnForward"
            OnClick="btnForward_Click" />
A: 

dear afshar

as its clear your Page (Module) does someting in Page_Load event and this event prevent potbacking your button.

I mean You try to post back, and Page_Load event run again and everything appear as the first time,

I had this problemt and resolveit by putting a

  if(!IsPostBack)
      DoSomething();
Nasser Hadjloo
A: 

var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); var postBackElement; function InitializeRequest(sender, args) { if (prm.get_isInAsyncPostBack()) args.set_cancel(true); postBackElement = args.get_postBackElement(); if (postBackElement.id == 'btnSearch') $get('UpdateProgress1').style.display = 'block'; } function EndRequest(sender, args) { if (postBackElement.id == 'btnSearch') $get('UpdateProgress1').style.display = 'none'; }
   <asp:GridView ID>

    <Columns>
      <asp:TemplateField>
         <HeaderTemplate>
         <asp:Label ID="Label2" runat="server" Text="Status"></asp:Label>  
          <asp:CheckBox ID="chkSelectAll" runat="server"  onclick="javascript:HighlightRow(this);"
          AutoPostBack="true"  ToolTip="Click here to select all checkboxes"
          OnCheckedChanged="chkSelectAll_CheckedChanged"/>
         </HeaderTemplate>
         <ItemTemplate >

         <asp:CheckBox ID="CheckBox1" onclick="javascript:HighlightRow(this);" 
                    AutoPostBack="true" runat="server"
                    OnCheckedChanged="CheckBox1_CheckedChanged1" />


        </ItemTemplate>

        </asp:TemplateField>

<asp:BoundField

    </Triggers>
    </asp:UpdatePanel>
      <asp:UpdateProgress ID="UpdateProgress1"  AssociatedUpdatePanelID="UpdatePanel1"  runat="server" ><ProgressTemplate>
             <asp:Image ID="Imgwait" runat="server" 
                 ImageUrl="~/Content/images/images/ApImages/001413_0.gif" />
             <asp:Label ID="Lblwait" runat="server" 
                 Text="Please wait while we process your request...." Font-Names="Tahoma" 
                 Font-Size="10px" ForeColor="#990000"></asp:Label>

Code behind protected void CheckBox1_CheckedChanged1(object sender, EventArgs e) { IMGDV.Visible = true;

} On checkbox checkchange event want to display pannel control but it is not dispalying pannel control help...

Hanuman