Javascript 保存数据 asp.net 后单击按钮显示警报消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10815773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:03:39  来源:igfitidea点击:

Show Alert message on button click after saving the data asp.net

javascriptasp.netalertcode-behind

提问by Geeth

I want to show a message "Successfully added" after saving the record to the database on button click which already having a JS function for some validation on the data. i have tried the following code but nothing is showing.

我想在单击按钮时将记录保存到数据库后显示一条消息“已成功添加”,该按钮已经具有用于对数据进行某些验证的 JS 函数。我尝试了以下代码,但没有显示任何内容。

ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert",
"<script>alert('" + "Successfully added" + "');</script>", false);

How to show the success message in a popup with at the end save process?

如何在最后保存过程的弹出窗口中显示成功消息?

回答by Romil Kumar Jain

Use Response.Write("<script>alert('Successfully added');</script>");on button code behind.

Response.Write("<script>alert('Successfully added');</script>");在后面的按钮代码上使用 。

回答by relower

try this,

尝试这个,

System.Web.HttpContext.Current.Response.Write("<script language=\"JavaScript\">alert(\"write here what you want\")</script>");