I’m trying to create an error message / notification component for our .net C# web application. The requirements are that multiple messages can be posted, that they persist through partial post backs, and have different types (sticky, error, notification).
I have a server-side method that captures these messages, and I am using the popular jQuery plug-in jGrowl to display these messages. See below:
public void ShowErrorMessage(string Message)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorMessage", "<script type=\"text/javascript\">$.jGrowl('" + Message + "', { sticky: true });</script>");
}
Currently I am firing the jGrowl script inside the ShowErrorMessage method using RegisterStartupScript approach which works fine for the first message but of course the RegisterStartupScript does not allow me to to fire Javascript on a whim. How can I fire an instance of jGrowl each time ShowErrorMessage is hit?
My JavaScript knowledge is limited. I am open to any suggestions or alternative methods. Thank you.