本文介绍了警报消息未在C#中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么警报消息未显示


我的CS代码在下面给出

Why the alert message is not showing


My cs code is given below

protected void Button1_Click(object sender, EventArgs e)
   {
       con.Open();
       com = con.CreateCommand();
       com.CommandText = "UPDATE news SET news = '" + txt1.Text.Trim() + "' where id='" + 1 + "'";
       try
       {
           int result=com.ExecuteNonQuery();
           if (result == 1)
           {
               ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Showalert0()", true);
               txt1.Focus();
           }

       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }
       con.Close();
   }




我的javasctipt代码在下面给出




My javasctipt code is given below

<script type="text/javascript">
    function Showalert2()
     {
        alert('News updated sucessfully.');
    }
</script>

推荐答案

protected void Button1_Click(object sender, EventArgs e)
   {
       con.Open();
       com = con.CreateCommand();
       com.CommandText = "UPDATE news SET news = '" + txt1.Text.Trim() + "' where id='" + 1 + "'";
       try
       {
           int result=com.ExecuteNonQuery();
           if (result == 1)
           {
               ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Showalert2()", true);
               txt1.Focus();
           }
 
       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }
       con.Close();
   }


这篇关于警报消息未在C#中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:18