开发者

JQuery: Is there a way to show status msg from code behind (asp.net)

开发者 https://www.devze.com 2023-01-17 08:46 出处:网络
i am trying to figure out how to display message box after it done executing the server side code here is the code which works from the client side but still looking for a way to make it work from co

i am trying to figure out how to display message box after it done executing the server side code

here is the code which works from the client side but still looking for a way to make it work from code-behind

.aspx

<div id="status"></div> 

script:

$("#status开发者_如何学JAVA").fadeTo(500, 1, function() { $(this).html("You are now registered!").fadeTo(7000, 0); })


Not sure why you are fading the status div twice.

I get it now. You are trying to show the div and then fade it away. Try this:

$("#status").html("You are now registered!").show().fadeTo(7000, 0);

Or you could use fadeIn and fadeOut to make them both fade, like this:

$("#status").html("You are now registered!").fadeIn(500).fadeOut(7000);

SERVER SIDE

To do it on the server side you would use the RegisterClientScriptBlock method of the ScriptManager class like so:

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "clientScript", "$(function() { $('#status').html('You are now registered!').fadeIn(500).fadeOut(7000); });", True)

The first parameter would be the page you are using it on. Then the type, which you can use me.GetType() to get, then a name for the method which isn't really important what you call it, and then the actual jQuery code. The last parameter is a boolean as to whether to include script tags or not. If you put them in the jquery code, set it to false, otherwise keep it true.

Also, you may need a ScriptManager control between the form tags on the page you use this on. And this was done using VB code.

0

精彩评论

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