Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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) { }
   }
Posted

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


try this simple code
 
Share this answer
 
Comments
BCD23 19-Dec-13 2:17am    
Ok thanx, but i want some attractive msgboxes. Like given in above code. how to display those?
navin ks 19-Dec-13 2:23am    
you can go deeeep here

http://slayeroffice.com/code/custom_alert/
you have to change the code
C#
sb.Append("toast("+"" + msg + ""+","+"" + cls + ""+");");


to

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



you missed the quotes here that's the problem.

I don't know what do you mean atrractive msg boxes..
 
Share this answer
 
Comments
BCD23 19-Dec-13 2:33am    
I have written CSS for messageboxes, I dnt want in built msgboxes. I want to place them at a specified locaition

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900