943,816 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 5846
  • ASP.NET RSS
Mar 11th, 2008
0

alert/message box

Expand Post »
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.
ASP.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
waterfall is offline Offline
24 posts
since Nov 2007
Mar 11th, 2008
0

Re: alert/message box

you mispelt javascript

javscript

javascript
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Mar 11th, 2008
0

Re: alert/message box

its still not working.
the values are updated in the database but alert is not displyed.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
waterfall is offline Offline
24 posts
since Nov 2007
Mar 11th, 2008
0

Re: alert/message box

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.

ASP.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 23
Solved Threads: 16
Posting Whiz in Training
plazmo is offline Offline
206 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC