回发后的Jquery消息框

发布于 2024-10-02 19:57:05 字数 1317 浏览 1 评论 0原文

我想在

我想展示 的 ASP.NET 应用程序中使用 this 插件回发后发出警报等。 我写了这段代码,但它不起作用。

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);

该代码适用于客户端:

<p>
        <strong>1.)</strong> <a href="http://www.csscody.com/#" onclick="csscody.alert(&#39;&lt;h1&gt;Information 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>

谢谢。

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('<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;">
            Info Message Popup Alert</a></p>
    <p>

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人│生佛魔见 2024-10-09 19:57:05

在 C# 代码中尝试一下

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

Try this in you C# code

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

红墙和绿瓦 2024-10-09 19:57:05

我相信 javascript 'onclick' 发生在回发之前。因此,如果您要在第一个页面加载时注册 jquery,那么它将在用户单击按钮时但在回发之前触发脚本。

您可以尝试使用“onload”而不是“onclick”注入代码,并在回发发生后注入它。这样,该对话框将在访问服务器后显示。

我希望这是有道理的。

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.

長街聽風 2024-10-09 19:57:05

您可以使用 scriptmanager.registerclientscript 而不是启动脚本来解决您的问题。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文