简体   繁体   中英

RegisterStartupScript in ButtonClick event of UserControl

I have a usercontrol with a form and a button. In the code behind of the button's click event, I save the data from the form to the database. After the save is successfully saved, I'd like to pop up a javascript alert. 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. Set this value to false and try again or remove the script block tags in your js. You can find out more details on msdn page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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