如何在ASP.NET中显示消息框?

编程入门 行业动态 更新时间:2024-10-10 01:17:44
本文介绍了如何在ASP.NET中显示消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在成功保存任何项目时显示一个消息框.我用谷歌搜索并尝试了不同的解决方案,但没有一个起作用.这是我正在使用的代码:

I want to show a message box on the successful save of any item. I googled it and tried different solutions, but none of them worked. Here is the code I am using:

try { con.Open(); string pass="abc"; cmd = new SqlCommand("insert into register values('" + txtName.Text + "','" + txtEmail.Text + "','" + txtPhoneNumber.Text + "','" + ddlUserType.SelectedText + "','" + pass + "')", con); cmd.ExecuteNonQuery(); con.Close(); Response.Write("<script LANGUAGE='JavaScript' >alert('Login Successful')</script>"); } catch (Exception ex) { } finally { con.Close(); }

(如果需要的话,我正在使用Firefox)

(I am using Firefox, if that matters)

推荐答案

@freelancer如果您使用的是ScriptManager,请尝试使用此代码获取消息.

@freelancer If you are using ScriptManager then try this code for message..

string script = "alert(\"Hello!\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);

更多推荐

如何在ASP.NET中显示消息框?

本文发布于:2023-11-27 16:14:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   如何在   ASP   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!