javascript alert???

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

javascript alert???

 
0
  #1
Mar 12th, 2008
how to use javascript alert in C# web forms?
im using this:
  1. Button.attributes.Add("onClick","javascript:alert('data saved successfully')");
but its not working.
i searched for it on internet but im getting tutorials etc for windows forms.
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: javascript alert???

 
0
  #2
Mar 12th, 2008
make sure "Button" is the name of your button that you are adding the attribute to.

Example:
  1. <asp:Button id="btnSubmit" .... runat="server" />
  2.  
  3. btnSubmit.attributes.Add("onClick","javascript:alert('data saved successfully')");
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: javascript alert???

 
0
  #3
Mar 13th, 2008
ive used the correct button id. rest of my code including code for javascript alert is working well without any error.but im not getting any alerts.
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: javascript alert???

 
0
  #4
Mar 13th, 2008
check to see if it is actually being added. You can do this by viewing the source of your document.

Search for your "id" and see if the onclick attribute is correctly put on the submit button.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: sms_net is an unknown quantity at this point 
Solved Threads: 0
sms_net sms_net is offline Offline
Newbie Poster

Re: javascript alert???

 
0
  #5
Mar 19th, 2008
Button1.Attributes.Add("onclick", "javascript:alert('data save successfully')");
The above code is working fine in my application, put this code in ur Page Load and see if it works.
Last edited by peter_budo; Mar 22nd, 2008 at 4:40 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 16
Reputation: razool is an unknown quantity at this point 
Solved Threads: 2
razool's Avatar
razool razool is offline Offline
Newbie Poster

Re: javascript alert???

 
0
  #6
Mar 22nd, 2008
Please do the following

In Aspx page write the following
  1. <script language="javascript">
  2. function MyAlert(var msgStr)
  3. {
  4. alert(msgStr);
  5. }
  6. </script>

In aspx.cs page

Button.attributes.Add("onClick","MyAlert('myMessage');");





Originally Posted by waterfall View Post
how to use javascript alert in C# web forms?
im using this:
  1. Button.attributes.Add("onClick","javascript:alert('data saved successfully')");
but its not working.
i searched for it on internet but im getting tutorials etc for windows forms.
Last edited by peter_budo; Mar 22nd, 2008 at 4:39 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC