I have a radiobutton (in updatepanel) and in checkchanged event I’m displaying a message to user. But div is in masterpage and page is not rendering, that’s why I can’t display message.
Is it possible to solve this? Btw I’m using class to display messages.
Here is my codes.
public static void setError(System.Web.UI.Page p, string title, string error, string type)
{
Literal literal = p.Master.FindControl("ltMessage") as Literal;
if (type == "error")
{
literal.Text = "<div id=\"alertError\" style=\"display:none; color:#fff; text-align:center; padding: 8px 10px 9px; width:auto; position:relative; background:#cc0000;\"><h3>" + title + "</h3><p>" + error + "</p></div>";
//literal.Text = "<div id=\"alert\" class=\"error message\"><h3>" + title + "</h3><p>" + error + "</p></div>";
StringBuilder sb = new StringBuilder();
sb.Append("$(function() { ");
sb.Append(" $('#alertError').toggle({");
sb.Append(" width: 400");
sb.Append(" });");
sb.Append("});");
if (HttpContext.Current.CurrentHandler is Page)
{
Page pa = (Page)HttpContext.Current.CurrentHandler;
if (ScriptManager.GetCurrent(pa) != null)
{
ScriptManager.RegisterStartupScript(pa, typeof(Page), "alert", sb.ToString(), true);
}
else
{
pa.ClientScript.RegisterClientScriptBlock(typeof(Page), "alert", sb.ToString(), true);
}
}
}
}
I fixed it. I put my div in updatepanel which was in the masterpage. And now it works perfect.