1

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')**">

1 Answer 1

2

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

7
  • 1
    I get a nervous tick whenever I have to maintain code that has UpdatePanel controls. Invariably, people see how "easy" it is to use them and start putting way too many of them on a page. Commented Jun 22, 2013 at 15:32
  • 1
    they are totally abused. I have seen terrible usage - multiple nesting, wrapping vast amounts of content etc.. But for certain things they are useful. Just must only be used for good and never evil Commented Jun 22, 2013 at 15:33
  • 1
    @BloopieBloops - no offense meant, I was just venting, because I have worked on so many projects where UpdatePanels became the golden hammer and every problem was a nail. Commented Jun 22, 2013 at 16:15
  • None taken @Karl, it's just like advice, anyways tried __doPostBack('UpdatePanel1', ''); . Still full update, why is it Updatepanel instead of the button? Commented Jun 22, 2013 at 16:34
  • 1
    sorry it doesn't. This link may help stackoverflow.com/questions/6583501/… Commented Jun 24, 2013 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.