UpdatePanel and __doPostBack

Last post 03-06-2007 9:32 AM by gt1329a. 2 replies.

Sort Posts:

  • UpdatePanel and __doPostBack

    01-24-2007, 4:06 PM
    • Loading...
    • cbretana
    • Joined on 09-19-2003, 8:00 PM
    • Southern California
    • Posts 7

    My app loads one of several dynamically generated reports, implemented as user Controls, (*.ascx files) into an Update Panel.  I am trying to do this without a page postback.  However, client side code needs to validate several things before issuing the asynchronous request.  In IE, I was using an ASP.Net custom Validator control hooked to a client side script
    (GenerateReport(sender, e)  {...}  
    to control this, (using e.valid = true/false; to control whether the asynchronous request to update the content in the UpdatePanel was sent or not, but I have discovered that Firefox does not implement ASP.Net Validators properly.

    So now I am trying to accomplish the same functionality simply using a client side script that calls __doPostBack(eventTarget, eventArgs); 
    But I can't seem to get the __doPostBack to call the Microsoft AJAX asynhcronous call, instead of doing a complete page postback.

    How do I do that?  Or  is there a better way to do this. 

    Another option I have considered is to put the user control into a web service, that somehow just returns the innerHTML of the user5 control rendering process, but I can;t seem to figure that out either..

     

    ideas anyone?

    Charles Bretana Jr
  • Re: UpdatePanel and __doPostBack

    01-26-2007, 3:09 PM
    • Loading...
    • gddub
    • Joined on 01-26-2007, 7:45 PM
    • Posts 2

    I've been fighting the same problem the last couple of days.  Here is what I just finally came up with...

     I write the __doPostBack on the server side and insert it into an onClick event on a control.

    String sOnClick

    = "__doPostBack('" + this.UpdatePanel1.UniqueID + "','eventarg1$eventarg2');";  // the Update Panel's UniqueID will call the asynchronous request and pass the event argument string

    e.Row.Attributes.Add("onClick", sOnClick); //  I'm adding this to a gridview, I'm guessing this will work elsewhere too.

    Then in the Page_Load I parse the event arguments and call the appropriate function

    String sEventArguments = this.Request.Params["__EVENTARGUMENT"];

    if(sEventArguments != null)

    {

         Int32 iDelimiter = sEventArguments.IndexOf('$');

         String sArgument = sEventArguments.Substring(iDelimiter + 1);

         if
    (sEventArguments.StartsWith("eventarg1"))

              EventFunction(sArgument);

    }

    I hope this helps.

    G

  • Re: UpdatePanel and __doPostBack

    03-06-2007, 9:32 AM
    • Loading...
    • gt1329a
    • Joined on 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 1,756

    You can use __doPostBack() to refresh an UpdatePanel, if you target the UpdatePanel itself.
     

    Encosia - ASP.NET, AJAX, and more.

    Latest article: Using jQuery to enhance ASP.NET AJAX progress indication
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter