简体   繁体   English

UserControl的ButtonClick事件中的RegisterStartupScript

[英]RegisterStartupScript in ButtonClick event of UserControl

I have a usercontrol with a form and a button. 我有一个带有表单和按钮的usercontrol。 In the code behind of the button's click event, I save the data from the form to the database. 在按钮的click事件后面的代码中,我将表单中的数据保存到数据库中。 After the save is successfully saved, I'd like to pop up a javascript alert. 保存成功保存后,我想弹出一个javascript警报。 I've tried the following: 我尝试过以下方法:

Control Caller = this;
ScriptManager.RegisterStartupScript(Caller, Caller.GetType(), " ", 
   @"<script language=javascript>alert('Asset successfully saved');</script>", true);

This doesn't work. 这不起作用。 What am I doing wrong, or even how do I debug this? 我做错了什么,甚至我该怎么调试呢?

It is because you have set the addScriptTags to true and you are also trying to add your own script tags in the js code. 这是因为您已将addScriptTags设置为true,并且您还尝试在js代码中添加自己的脚本标记。 Set this value to false and try again or remove the script block tags in your js. 将此值设置为false,然后重试或删除js中的脚本块标记。 You can find out more details on msdn page . 您可以在msdn页面上找到更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM