954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

alert/message box

Im using VS 2005 for web application.Im using message boxes but they are not working.i dont know what's the problem with my code.

if (drff.Read())
            {
                Button_Assign.Attributes.Add("onclick", "javscript:alert('Data saved successfully.')");
               
            }
            /*else
            {
                //Button_Assign.Attributes.Add("onclick", "javscript:alert('Data not saved.')");
             
            }


my data is saved successfully but im not getting the alert.same is the case with cancel/exit button.Please help me.

waterfall
Newbie Poster
24 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

you mispelt javascript

javscript

javascript

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

its still not working.
the values are updated in the database but alert is not displyed.

waterfall
Newbie Poster
24 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

what you have will not work because you are adding the onclick event after the button was already clicked. so after the page postsback you should get that alert when you press the button using your code.

use this.

if (drff.Read())
            {
                ClientScript.RegisterStartupScript(typeof(string), "success", "alert('Data saved successfully.');", true);   
            }
            else
            {
                ClientScript.RegisterStartupScript(typeof(string), "fail", "alert('Data not saved.');", true);
            }


this adds the alert to the page load, which is the place you want to add it.

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You