如何从代码后面调用javascript [英] how to call javascript from code behind

查看:64
本文介绍了如何从代码后面调用javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






来自代码隐藏的
我在按钮点击事件中调用脚本函数为

 Page.ClientScript.RegisterStartupScript( this  .GetType(), 调用我的函数  overlay('Saved Succesfully'),< span class =code-keyword> true ); 


来自default.aspx页面的
运行良好并指定已成功保存:文本到标签但是当我通过传递查询字符串加载页面为default.aspx?id = 98时弹出窗口正在加载但是值没有分配给标签,即保存成功文本没有传递给脚本函数可以任何人建议我如何解决这个问题,这就是我调用的函数

函数overlay(value){

el = document.getElementById('ovrly' );
$ ( '#ovrly')显示();

$('#<% = pbl.ClientID %> )的.text(值);

}

解决方案

('#ovrly')。show();


('#<% = pbl.ClientID %> ')。text (值);

}


我想错了分号。



 Page.ClientScript.RegisterStartupScript( this  .GetType(), < span class =code-string>调用我的函数,  overlay('Saved Succesfully') ; true ); 









 ScriptManager.RegisterStartupScript( this  .Page, this  .GetType(),  tmp < script type ='text / javascript'> disp_confirm();< / script>); 


Hi,


from code-behind am calling a script function in button click event as

Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "overlay('Saved Succesfully ')", true);


from default.aspx page is running good and assigning "saved successfully: text to the label but when i load a page by passing query string as default.aspx?id=98 it is the popup is loading but the value is not assigned to label i.e,"saved successfully" text is not passing to the script function can any one suggest me how to solve this and this is the function am calling

function overlay(value) {
                  
                   el = document.getElementById('ovrly');
                   $('#ovrly').show();

                   $('#<%= pbl.ClientID %>').text(value);

               }

解决方案

('#ovrly').show();


('#<%= pbl.ClientID %>').text(value); }


just missed the semicolon I think.

Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "overlay('Saved Succesfully ');", true);



or

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>disp_confirm();</script>", false);


这篇关于如何从代码后面调用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆