In BasePage class I overrided OnPreRender method:
public class BaseMainPage : BaseDataPage
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(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?
public class BaseMainPage : BaseDataPage
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(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?