使用ScriptManager.RegisterStartupScript从代码后面调用javascript函数 [英] Call to javascript Function from code behind using ScriptManager.RegisterStartupScript
问题描述
我在我的内容页面上使用Ajax Toolkit。我有一个Javascript代码,我想用后面的代码调用ScriptManager.RegisterStartupScript。
javaScript代码是: -
< pre lang =Javascript>< script type = text / javascript>
function disp_confirm(){
var r = jConfirm( 你的转变结束!你还想继续吗?)
if (r == true ){
jAlert( < span class =code-string>你按OK!)
}
else {
jAlert( 您按下取消!)
}
如何使用C#从后面的代码中调用这个javascript的disp_confirm()方法。
试试这个:
Page.ClientScript.RegisterStartupScript(this.GetType(),alert,disp_confirm();,true);
试试这个:
ScriptManager.RegisterClientScriptBlock( this .Page, this .GetType(),< span class =code-string> MyFun1, disp_confirm();, true );
--Amit
试用此代码
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),tmp,< 脚本 类型 =' text / javascript' > disp_confirm(); < / script > ,false);
问候
sarva
I am using Ajax Toolkit on my content page . I have an Javascript Code which i want to call from the code behind using ScriptManager.RegisterStartupScript.
The javaScript Code is :-
<script type="text/javascript">
function disp_confirm() {
var r = jConfirm("Your Shift End ! Do you still want to Continue ? ")
if (r == true) {
jAlert("You pressed OK!")
}
else {
jAlert("You pressed Cancel!")
}
How to call this disp_confirm()method of javascript from the code behind using C# .
Try this :
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "disp_confirm();", true);
Try this:
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "disp_confirm();", true);
--Amit
try this Code
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>disp_confirm();</script>", false);
regards
sarva
这篇关于使用ScriptManager.RegisterStartupScript从代码后面调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!