Client-side update request for UpdatePanel, can it be done?

Last post 05-15-2007 2:34 AM by rx78gp03. 5 replies.

Sort Posts:

  • Client-side update request for UpdatePanel, can it be done?

    04-30-2007, 6:49 PM
    • Participant
      959 point Participant
    • offwhite
    • Member since 09-19-2005, 5:08 PM
    • Milwaukee, WI
    • Posts 206

    I see everywhere the the triggers attached to PostBack events cause the UpdatePanel to be updated, but what if i I want the UpdatePanel to just do a PostBack and get an update from the server? How could I use the client-side to trigger the update?

     

    Brennan Stehling
    http://www.smallsharptools.com/
    http://www.linkmindr.com/
  • Re: Client-side update request for UpdatePanel, can it be done?

    05-01-2007, 1:27 PM
    Answer
    • Participant
      959 point Participant
    • offwhite
    • Member since 09-19-2005, 5:08 PM
    • Milwaukee, WI
    • Posts 206

    I found a way to make this work. I added a LinkButton to the page inside of the UpdatePanel. I just wanted to access the href value which holds onto the Javascript which raises the click event. I specifically left the text of the link empty so that it is not displayed. The following Javascript causes the PostBack event to be triggered.

    function updateDisplay() {
        var link = document.getElementById('<%= lbUpdate.ClientID %>');
        var script = link.href.substring(link.href.indexOf(":")+1)
        eval(script);
    }
    

    This code gets the LinkButton element and gets the substring from the href for just the script code because it prefixes it with "Javascript:" which cannot be placed in the eval statement which runs the script. This works well. I still would like something a bit more directly supported by the framework but so far I cannot find documentation on doing this.

    Brennan Stehling
    http://www.smallsharptools.com/
    http://www.linkmindr.com/
  • Re: Client-side update request for UpdatePanel, can it be done?

    05-02-2007, 9:32 PM
    • Member
      4 point Member
    • glassware
    • Member since 04-05-2007, 9:24 PM
    • Posts 2

    There's an easier way to do this.  Let's say you have an UpdatePanel control called MyUpdatePanel.  Now, an UpdatePanel control has no events, but the client web browser doesn't know that.  You can pretend that an event fired using __doPostBack as follows:

      

    __doPostBack('<%=MyUpdatePanel.ClientID%>','customPostback');
     The client-side Javascript interface will happily generate a postback for you and tell the server that the 'customPostback' event fired.  The server will skim through its list of events and notice that there is no handler for the 'customPostback' event.  As a result, no events will fire, but the UpdatePanel will refresh.

  • Re: Client-side update request for UpdatePanel, can it be done?

    05-02-2007, 9:54 PM
    • Participant
      959 point Participant
    • offwhite
    • Member since 09-19-2005, 5:08 PM
    • Milwaukee, WI
    • Posts 206

    I suppose I could handle the event with the generic RaisePostBack event and key the action on the parameter. What my page is doing is using an asmx Web Service to carry out an action and then I need the databound controls to be refreshed. I explicitly call the data binding methods in the action I set up with the LinkButton. I do like your suggestion.

    Thanks


    Brennan Stehling
    http://www.smallsharptools.com/
    http://www.linkmindr.com/
  • Re: Client-side update request for UpdatePanel, can it be done?

    05-03-2007, 8:52 AM

    Hey

    I have previously solved the same problem by using a timer with a interval of 10 msec and then disabling it after first roundtrip.

    The above solution does not trigger the updateprogress. Can I somehow trigger the updateprogress the same way without using a timer?

  • Re: Client-side update request for UpdatePanel, can it be done?

    05-15-2007, 2:34 AM
    • Member
      68 point Member
    • rx78gp03
    • Member since 07-05-2006, 1:10 PM
    • Posts 53

    in the same manner, is it possible to cause an updatePanel to update if this script is not inside the update panel, for example:

    <asp:updatePanel ID="updatePanel1" runat="server">
    <contentTemplate>
    ...
    </contentTemplate>
    </asp:updatePanel>

    <asp:Panel runat="server" ID="Panel1">
    <a onclick="document.form1.submit();; return false;" title="Close">X</a>
    ...
    </asp:Panel>

    basically what's inside the contentTemplate are search results using dataList, there are some Item_bound items that needs to be refreshed after some events has been fired in the Panel.

    possible?

Page 1 of 1 (6 items)