开发者

Jquery Message Box After Postback

i want to use this plugin in my asp.net application

i want to show Alert or etc after postback. i wrote this code but it does not work.

string a = null;
a = "csscody.alert('<h1>Information Alert</h1><em>low     level</em><br/><p>© All rights reserved 2006-2010.  </p><p> jQuery examples site  <a href=\\'http://www.csscody.com/\\'>www.csscody.com</a> </p>');return false;";
 ScriptManager.RegisterStartupScript(Page, GetType(), "script", a, true);

This code works Client Side :

<p>
        <strong>1.)</strong> <a href="http://www.csscody.com/#" onclick="csscody.alert(&#39;&lt;h1&gt;Informatio开发者_开发知识库n Alert&lt;/h1&gt;&lt;em&gt;low level&lt;/em&gt;&lt;br/&gt;&lt;p&gt;&copy; All rights reserved 2006-2010. &lt;/p&gt;&lt;p&gt; jQuery examples site  &lt;a href=\&#39;http://www.csscody.com/\&#39;&gt;www.csscody.com&lt;/a&gt; &lt;/p&gt;&#39;);return false;">
            Info Message Popup Alert</a></p>
    <p>

Thanks.


Try this in you C# code

ClientScript.RegisterClientScriptBlock(typeof(Page), "yourKey", "$().ready(function () { csscody.alert('Hello')});", true);


I believe that the javascript 'onclick' occurs before the postback. Therefore, if you were to register the jquery on the first page load, then it will trigger the script when the user clicks on the button, but before the postback.

You can try to inject the code using 'onload' instead of 'onclick' and inject it after the postback occurs. That way the dialog will show up after the trip to the server.

I hope that makes sense.


You can use scriptmanager.registerclientscript instead of startup script that will solve your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜