RegisterStartupScript and more than one partial postbacks

2 posts, 1 answers
  1. Igor
    Igor avatar
    10 posts
    Member since:
    Oct 2013

    Posted 01 Apr 2014 Link to this post

    In BasePage class I overrided OnPreRender method:
        public class BaseMainPage : BaseDataPage
            protected override void OnPreRender(EventArgs e)

                if (!string.IsNullOrWhiteSpace(ExceptionHelper.MessageUI)) 
                    string script2run = @" $(window).load(function () { alert('" + ExceptionHelper.MessageUI + "'); }); ";

                    // handle exception
                    ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), script2run, true);

                    // reset the message
                    ExceptionHelper.MessageUI = null;

    This code displays alert message to user. The problem is when I have more than one partial postbacks the code doesn't work because once the method run then ExceptionHelper.MessageUI is null.

    How can I solve the problem?

  2. Answer
    Eyup avatar
    3320 posts

    Posted 04 Apr 2014 Link to this post

    Hi Igor,

    Please note that generally, Response.Write or direct script registering on ajax requests is not supported:

    You can check the the following sample for an alternative solution:

    In addition, you can go through:

    Hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top