确认代码后面的框javascript不弹出 [英] confirm box javascript in code behind not popping up

查看:57
本文介绍了确认代码后面的框javascript不弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个代码,该代码使用javascript的确认框.我使用

Hi,

I have a code that uses a confirm box from javascript. I call it from code behind using

ClientScript.RegisterClientScriptBlock(this.GetType(), "Error", "Confirm(''Do you want to overwrite the file?'');");

从后面的代码中调用它.当它传递到此行时,它不会弹出.它的作用是继续到下一行,然后在到达函数的最后一行时弹出对话框.有什么想法吗?

谢谢,

.. it does not pop-up when it passes to this line. What it does is it continues to the next line and then the dialog box pops-up when it reaches the last line of the function. Any ideas?

Thanks,

推荐答案

您的代码是服务器端代码,它所要做的只是说应在响应中呈现此脚本".当您碰到那行代码时,它不会在javascript中弹出-因为它尚未返回到客户端-您仍在运行服务器端代码.

您的功能需要完成,它将在页面上注册脚本,然后浏览器将在客户端上
Your code is server side code, all it is doing is saying ''this script should be rendered in the response''. When you hit that line of code, it won''t pop up in javascript - because it hasn''t returned to the client yet - you''re still running server side code.

You function will need to finish, it will register the script on the page and then it will be processed on the client by the browser


hi,
您需要指出script参数中提供的脚本是否用< script>包装.元素块与否.重新编写如下代码,
ClientScript.RegisterClientScriptBlock(this.GetType(),"Error","Confirm(''是否要覆盖文件?'');",true);
添加"true"值表示要添加脚本标签.希望这会有所帮助.

you need to indicate whether the script provided in the script parameter is wrapped with a <script> element block or not. Re write the code like following,
ClientScript.RegisterClientScriptBlock(this.GetType(), "Error", "Confirm(''Do you want to overwrite the file?'');",true);
adding "true" value indicates to add script tags. Hope this will help.


这篇关于确认代码后面的框javascript不弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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