Here is a sample function to show a floating pop up notification bar in ASP.NET…….
take a page, put an updatepanel and add a label into it, inject rest of the stuff into label, eventuallyCall the function against a button click event.
// call MiscUtil. ShowMessage(lbl,”hello”,false);
Public class MiscUtil
{
public static void ShowMessage(Label label, string message, bool isError)
{
string strInterval = string.Empty;
if (message == string.Empty) return;
try
{
AlwaysVisibleControlExtender avce = new AlwaysVisibleControlExtender();
avce.TargetControlID = label.ID;
avce.ScrollEffectDuration = .1f;
label.Parent.Controls.Add(avce);
label.ForeColor = System.Drawing.Color.Black;
label.Text = "PADDING: 5PX;\ STYLE="\" DIVPARENT\>";label.Text += "ALIGN: LEFT;\>";
label.Text += "[Photo]/ />";label.Text += " " + "" + message + "";label.Text += "";label.Text += "ALIGN: RIGHT; PADDING-RIGHT: 10PX; WHITE-SPACE: NOWRAP\ STYLE="\">";
label.Text += " onclick=\"javascript:hideMeClick('" + label.ClientID + "')\"title=\"Hide Me\">Hide Me";
label.Text += "";
strInterval =ConfigurationManager.AppSettings["AlertInterval"].ToString();//get the time to show the notification
ScriptManager.RegisterClientScriptBlock(label,typeof(MiscUtil), "MiscUtil","window.setTimeout(function(){hideMeClick('" + label.ClientID+ "');}, '" + strInterval + "')", true);
if (isError)
{
label.ForeColor = System.Drawing.Color.Red;label.Font.Bold = true;
}
label.CssClass = "CommonAlertMessage";
}
catch (Exception ex)
{
label.ForeColor = System.Drawing.Color.DodgerBlue;label.Text = message;
if (isError)
{
label.ForeColor = System.Drawing.Color.Red;label.Font.Bold = true;
}
}
}
}
// Here is the script codefunction
hideMeClick(ctlId)
{
document.getElementById(ctlId).style.display = 'none';
}
label.Parent.Controls.Add(avce);
ReplyDeleteThe Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
sometimes this exception came y it is sos can u help plz?