SkyeBoniwell
SkyeBoniwell

Reputation: 7092

asp.net button does not fire inside updatepanel

I have a button(btnTransferAccept) inside an update panel that is not firing. I added it as a trigger and it still does nothing. The button is supposed to fire a javascript alert. If I remove the button outside of the updatepanel, it works fine.

Any ideas? Thanks

Here is my code:

 <asp:UpdatePanel ID="pnlTransferOwnership" ChildrenAsTriggers="true" runat="server" >
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="gvTransferOwner" />
            <asp:AsyncPostBackTrigger ControlID="btnTransferAccept" />
        </Triggers>
        <ContentTemplate>

            <asp:Gridview id="gvTransferOwner" CellPadding="0" GridLines="None" CellSpacing="0" runat="server" AutoGenerateColumns="false"
             onrowcommand="gvTransferOwner_RowCommand">
                <Columns>
                    <asp:TemplateField>    
                        <ItemTemplate>
                            <asp:HiddenField ID="hfID" Value='<%#Eval("ID") %>' runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="FirstName" HeaderText="First Name"  />
                    <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                    <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" />
                    <asp:buttonfield buttontype="Button" commandname="Select" headertext="Transfer" text="Select" />
                </Columns>
            </asp:Gridview>

            <div class="ui-dialog-buttonset">
                <asp:Button ID="btnTransferAccept" runat="server" CssStyle="display: none;" Text="Transfer" cssClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

Upvotes: 1

Views: 3370

Answers (3)

Sham
Sham

Reputation: 59

while doin update panel tryto put all the ctrls with in the update panel

       </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="gvTransferOwner" />
        <asp:AsyncPostBackTrigger ControlID="btnTransferAccept" />
        </Triggers>
       </asp:UpdatePanel>

   and the whole with in a <div>

Upvotes: 0

user2063626
user2063626

Reputation:

You need to put your javascript alert in PageLoad event instead of window onload or jquery ready event.

Below link would give you detailed explanation.

http://encosia.com/document-ready-and-pageload-are-not-the-same/

Upvotes: 1

catalin ilie
catalin ilie

Reputation: 121

Not sure if this is the problem, but try to move the triggers below the content template. Your code should look like this:

<ContentTemplate>
....
</ContentTemplate>
<Triggers>
  <asp:AsyncPostBackTrigger ControlID="gvTransferOwner" />
  <asp:AsyncPostBackTrigger ControlID="btnTransferAccept" />
</Triggers>
</asp:UpdatePanel>

Upvotes: 1

Related Questions