开发者

Error Message/Notification Component for .NET C# web app using jQuery (jGrowl)

开发者 https://www.devze.com 2022-12-09 06:35 出处:网络
I’m trying to create an error message / notification component for our .net C# web applicat开发者_开发技巧ion.The requirements are that multiple messages can be posted, that they persist through part

I’m trying to create an error message / notification component for our .net C# web applicat开发者_开发技巧ion. 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.


Could you give a little more info. You mentioned doing partial postbacks. Are you doing a full postback or a partial? If partial, how so...through an updatepanel?

One thing to note is that the RegisterStartupScript will only register 1 instance of that script if it's always called from the same place. It's using this.GetType() and "ErrorMessage" to check to see if it's already been registered. If you call it with a different message, that script won't register since it's still the same type and "ErrorMessage".

0

精彩评论

暂无评论...
验证码 换一张
取 消