Avoid page load event for user controls

6 posts, 0 answers
  1. paramvir
    paramvir avatar
    1 posts
    Member since:
    Jan 2009

    Posted 06 Jan 2009 Link to this post

    I created a page and added some user controls using RAD ajax panel. When i click on a button in the user control, the control sends an AJAX request and reloads the control as per the logic. 
    But the problem is that every time I do an ajax postback page load event for all the controls gets fired. 
    Is there a way to avoid it?
  2. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 06 Jan 2009 Link to this post

    Hey,

    I don't know if this works with Telerik or not, but the ScriptManager control has a property specifying whether the current page process is an async postback process or not.  The property for the ScriptManager is:  http://www.asp.net/Ajax/Documentation/Live/mref/P_System_Web_UI_ScriptManager_IsInAsyncPostBack.aspx

    So you can do:

    ScriptManager manager = ScriptManager.GetCurrent(this.Page);
    if (manager.IsInAsyncPostBack) { }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 06 Jan 2009 Link to this post

    Hey,

    The RadAjaxManager also has an IsAjaxRequest property that is more properly used for partial postback requests too.

    RadAjaxManager m = RadAjaxManager.GetCurrent(this.Page);
    m.IsAjaxRequest
  5. paramvir
    paramvir avatar
    1 posts
    Member since:
    Nov 2008

    Posted 06 Jan 2009 Link to this post

    But isn't there any way in which I can pass the information about which part is going under ajax postback and getting that information on server.
  6. siva prakash
    siva prakash avatar
    2 posts
    Member since:
    Jul 2009

    Posted 31 Jul 2009 Link to this post

    Hi paramvir

    please let me know if you get any solution
  7. Albert Shenker
    Albert Shenker avatar
    551 posts
    Member since:
    Mar 2004

    Posted 31 Jul 2009 Link to this post

    I may not be understanding what it is you are trying to do, but my question would be, why is the page_load event firing in your user controls a problem? Ignoring AJAX for a moment, these events fire as part of the normal ASP.net page lifecycle during a postback. If you have particular initialization code you run in the user control page_load event, and you don't want this code run during a postback (ie in response to a button being clicked, or something else that raises a postback), you can wrap this code in a "if not page.ispostback" block. If, instead of a postback, your page initializes an Ajax Request (as a result of an ajaxified control on one of your user controls), then the page_load events of your other controls will fire, but the ispostback block will prevent any of the code within them from executing. Is this not what you want to accomplish?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017