문제

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

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top