警报框(或msgbox)未显示在页面上 [英] Alert box ( or msgbox ) is not displayed on a page

查看:102
本文介绍了警报框(或msgbox)未显示在页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我是ASP.net的新手。我通过使用一些图像为背景设计了一个页面。一切都很好。现在,我在保存数据后尝试显示消息boc或任何警告消息时,它不会显示。数据保存得当。不显示bt消息。是因为图像吗?如何在这些图像上方显示消息或警告框。请帮帮我。我的警报框代码如下:



hello friends,
I am new to ASP.net. I have designed a page by using some images for background. Everything was fine. Bt now whien i try to display a message boc or any alert msg after saving the data it is not displayed. Data is saved properly. bt message is not displayed. Is it because of Images? How to display a msg or alert box above those images. Please help me out. my code for alert box is as follows:

void CallToast(String msg, String cls)
    {
       System.Text.StringBuilder sb = new System.Text.StringBuilder();
       sb.Append("<script language='javascript'>");
       sb.Append("toast("+"" + msg + ""+","+"" + cls + ""+");");
       sb.Append("</script>");
     ScriptManager.RegisterStartupScript(this, this.GetType(), "ajax", sb.ToString(), false);

    }

  protected void Button1_Click(object sender, EventArgs e)
   {
       try
       {
           sqlhelper = new SQLHelper();
            query = String.Format("Insert into Issues(IssueId,Name,EmailId,ContactNumber,ModelNo,Issue,ToDo)values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",generateId(),TextBox1.Text,TextBox2.Text,TextBox3.Text ,TextBox4.Text,TextBox5.Text,TextBox6.Text );
          long r =  sqlhelper.ExecuteNonQuery(query);
          if (r == 0)
          {
              CallToast("Sorry! Please try again", "toast-error");
          }
          else
          {
              CallToast("Saved Successfully", "toast-success");
          }
       }
       catch (Exception ex) { }
   }

推荐答案

ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Your request for change in  code has been sent to Nasa');", true);





尝试这个简单的代码



try this simple code


你必须更改代码

you have to change the code
sb.Append("toast("+"" + msg + ""+","+"" + cls + ""+");");





to





to

sb.Append("alert("+"\"" + msg + ""+","+"" + cls + "\""+");");







你错过了这里的报价问题。



我不知道你是什么意思atrractive msg box ..




you missed the quotes here that's the problem.

I don't know what do you mean atrractive msg boxes..


这篇关于警报框(或msgbox)未显示在页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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