alert/message box

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 24
Reputation: waterfall is an unknown quantity at this point 
Solved Threads: 0
waterfall waterfall is offline Offline
Newbie Poster

alert/message box

 
0
  #1
Mar 11th, 2008
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.
  1. if (drff.Read())
  2. {
  3. Button_Assign.Attributes.Add("onclick", "javscript:alert('Data saved successfully.')");
  4.  
  5. }
  6. /*else
  7.   {
  8.   //Button_Assign.Attributes.Add("onclick", "javscript:alert('Data not saved.')");
  9.  
  10.   }
  11.  

my data is saved successfully but im not getting the alert.same is the case with cancel/exit button.Please help me.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: alert/message box

 
0
  #2
Mar 11th, 2008
you mispelt javascript

javscript

javascript
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 24
Reputation: waterfall is an unknown quantity at this point 
Solved Threads: 0
waterfall waterfall is offline Offline
Newbie Poster

Re: alert/message box

 
0
  #3
Mar 11th, 2008
its still not working.
the values are updated in the database but alert is not displyed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 206
Reputation: plazmo is an unknown quantity at this point 
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: alert/message box

 
0
  #4
Mar 11th, 2008
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.

  1. if (drff.Read())
  2. {
  3. ClientScript.RegisterStartupScript(typeof(string), "success", "alert('Data saved successfully.');", true);
  4. }
  5. else
  6. {
  7. ClientScript.RegisterStartupScript(typeof(string), "fail", "alert('Data not saved.');", true);
  8. }

this adds the alert to the page load, which is the place you want to add it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC