如何创建一个弹出消息框以在.net C#Web应用程序中显示错误消息 [英] How to create a pop-up message box to display error message in .net c# web-applications

查看:75
本文介绍了如何创建一个弹出消息框以在.net C#Web应用程序中显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在服务器端创建一个弹出消息框,以便在保存过程失败时在弹出消息框中显示错误消息吗?

Does anyone know how can I create a pop-up message box in server side, so that it will display the error message in the pop-up message box when save process is failed?

示例:

   protected void btnSave_Click(object sender, EventArgs e)
   {
       try
       {
           using (TransactionScope scope = new TransactionScope())
           {
               //save process

               scope.Complete();
               Response.Redirect(url);
           }
       }
       catch (TransactionAbortedException ex)
       {
          //pop-up message box to show error message
       }
       catch (ApplicationException ex)
       {
          //pop-up message box to show error message
       }
   }

当保存过程失败时,如何在捕获中创建一个弹出消息框,以将错误消息框弹出给用户?

How can I able to create a pop-up message box within the catch to pop-up the error message box to the user when the save process is failed?

推荐答案

尝试使用 Page.RegisterStartupScript ClientScript.RegisterStartupScript 方法.

这篇关于如何创建一个弹出消息框以在.net C#Web应用程序中显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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