Server event on UpdatePanel postback?

Last post 08-29-2007 1:54 PM by VladimirZinchenko. 4 replies.

Sort Posts:

  • Server event on UpdatePanel postback?

    08-29-2007, 6:16 AM
    • Member
      27 point Member
    • VladimirZinchenko
    • Member since 03-09-2007, 5:37 AM
    • Saint-Petersburg, Russia
    • Posts 11

    Hello!

    I'm creating a custom WebControl that have an UpdatePanel inside. On client side I have a js-based UpdatePanel postback (code below) and I want to catch an event in my control when the UpdatePanel is posted back to the server. The thing is that I want to raise another event from my control in a reaction. Are there any "standard" ways to do that?

    As a workaround I can place a HiddenField inside UpdatePanel and change its value before posting back an UpdatePanel, then catch HiddenField.Changed event in my control, but I want to avoid such solution as much as possible.

    JS class method for update UpdatePanel (where this.updatePanel is the updatePanel control)

    	postBack : function()
    	{
    		var prm = Sys.WebForms.PageRequestManager.getInstance();
    		prm._doPostBack (this.updatePanel.id, '');
    	}
    
    The less I have the more I gain
  • Re: Server event on UpdatePanel postback?

    08-29-2007, 8:36 AM
    • Contributor
      3,121 point Contributor
    • sujitm
    • Member since 05-23-2007, 9:01 AM
    • Pune
    • Posts 512

    You'll have to implement IPostbackEventHandler interface if you want to enable event handling in your control. I think that should be enough to get it working.

    - Sujit

    Dont forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Server event on UpdatePanel postback?

    08-29-2007, 8:39 AM
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 2:25 PM
    • Bristol, CT
    • Posts 1,422
  • Re: Server event on UpdatePanel postback?

    08-29-2007, 10:12 AM
    • Star
      8,978 point Star
    • dwhite
    • Member since 02-08-2007, 2:25 PM
    • Bristol, CT
    • Posts 1,422

    Also, check out this post: http://forums.asp.net/t/1151141.aspx

    -Damien

    Visoft, Inc - Home | Blogs

    Latest Blog Post: Silverlight DataBinding Bug
  • Re: Server event on UpdatePanel postback?

    08-29-2007, 1:54 PM
    Answer
    • Member
      27 point Member
    • VladimirZinchenko
    • Member since 03-09-2007, 5:37 AM
    • Saint-Petersburg, Russia
    • Posts 11

    Thank you guys! 

     Sujit,

    Yes, I indeed tried implementing IPostbackEventHandler, but for some strange reason, RaisePostbackEvent was never called. Probably there's something wrong with my understanding of how it works.

     Damien,

    Actually prm._doPostBack is invoked through __doPostBack, so approaches are pretty the same.

    Finally, I came to conclusion to override UpdatePanel class (anyway I needed to add some CSS class styling to it) and override its RenderChildren method to analyze IsInPartialRendering property and raise an event if needed.

    What I actually wanted is to create a custom Web control that allows creation the contents of UpdatePanel dynamically through events it issues. In my case building contents can be quite time consuming, that's why I want to do it only when the UpdatePanel actually gets updated.

    The less I have the more I gain
Page 1 of 1 (5 items)
Microsoft Communities