2010-11-16 37 views
0

後,我想用this插件在我的asp.net應用程序jQuery的消息框回傳

我想顯示回發後報警或等。 我寫了這段代碼,但它不起作用。

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> 

感謝。

回答

2

你試試這個C#代碼

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

+0

偉大:)我的代碼有什麼問題?在我顯示此警報後,我的下拉列表將被隱藏!你有這個問題嗎? – Shahin 2010-11-25 07:23:46

-1

您可以使用scriptmanager.registerclientscript而不是啓動腳本來解決您的問題。

+0

什麼是scriptmanager.registerclientscript和ScriptManager.RegisterStartupScript之間之探源? – Shahin 2010-11-16 07:32:55

+0

它不起作用。 – Shahin 2010-11-16 07:35:13

+0

我可以顯示Jquery Dialog Server端,但是我不能用這個插件做同樣的事情! – Shahin 2010-11-16 07:38:21

0

我相信javascript'onclick'發生在回發之前。因此,如果您要在第一次加載頁面時註冊jquery,那麼當用戶單擊按鈕時但在回發之前,它將觸發腳本。

您可以嘗試使用'onload'而不是'onclick'注入代碼並在回發發生後注入代碼。這樣,在訪問服務器之後,對話框就會顯示出來。

我希望是有道理的。