LuxuryWaffles
LuxuryWaffles

Reputation: 1708

__PostBack and updatePanel doing Full Page Update

I have a LiteralText which changes data when i click my control. I read up some guides and if I update the LiteralText within the UpdatePanel, it should only do a partial update but it updates the entire page.

I also read up another guide which says changing my __doPostBack to the clientID but didn't work too.

So here is my aspx side code:

<div id="modalbox" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
    aria-hidden="true">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"  ChildrenAsTriggers="true" UpdateMode="Conditional">
        <ContentTemplate>
           //Some Codes
                    <asp:Literal ID="modalTitle" runat="server"></asp:Literal>
           //More Codes
        </ContentTemplate>
    </asp:UpdatePanel>

My doPostBack code:

        <script type="text/javascript">
            function changeModalTitle(eventTarget, parameter) {
                __doPostBack('<%=modalboxStaff.ClientID%>;', parameter)
            }
        </script>

And the code that calls both codes:

    <a href='#modalbox' data-toggle='modal' runat="server" id="modalboxStaff" **onclick="javascript:changeModalTitle('AddStaff', 'Sup World')**">

Upvotes: 1

Views: 2106

Answers (1)

Crab Bucket
Crab Bucket

Reputation: 6277

It's only going to trigger a partial postback if the control triggering the postback is in the update panel or the control is referenced in the triggers collection of the update panel.

Could that be the issue?

to use __doPostBack to trigger the partial postback - you would need to reference the updatepanel ID in the __doPostBack call e.g.

__doPostBack('btnInsideUpdatePanel', '');

It's worth noting that the first argument is the ID not theClientID. If the clientID is used then you don't get the correct event handling on postback. Check out the answer on this forum

This article gives details

http://encosia.com/easily-refresh-an-updatepanel-using-javascript/

Any help?

EDIT

I would consider changing your anchor into a Link button. The anchor html control won't raise page events in the same way as a link button (although i believe what you have done can trigger a partial postback to be fair).

and the below link is pretty much doing what you are which might be helpful if you haven't seen it

http://weblogs.asp.net/jeffreyzhao/archive/2008/04/26/refresh-the-updatepanel-using-javascript-code.aspx

Cheers

Upvotes: 2

Related Questions