簡體   English   中英

回發后的jQuery消息框

[英]Jquery Message Box After Postback

我想在我的asp.net應用程序中使用插件

我想在回發后顯示Alert或其他內容。 我寫了這段代碼,但沒有用。

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>

謝謝。

在您的C#代碼中嘗試一下

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

我認為javascript“ onclick”發生在回發之前。 因此,如果要在第一頁加載時注冊jquery,則當用戶單擊按鈕時,但在回發之前,它將觸發腳本。

您可以嘗試使用“ onload”而非“ onclick”注入代碼,並在發生回發后注入代碼。 這樣,對話框將在服務器訪問之后顯示。

我希望這是有道理的。

您可以使用scriptmanager.registerclientscript代替啟動腳本來解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM