Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 15th, 2004, 11:31 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default javascript in asp.net

Hi,

i have whole of bunch of javascript code for the asp.net and how do i check if the javascript is enabled on the client machine...

is javascript is not enabled i just want to display a message asking them to enable javascript...

Thank U.


  #2 (permalink)  
Old September 15th, 2004, 01:08 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

Something like this....

<span id='jsEn'>
Please enable JavaScript.
</span>
<script type='text/javascript'>
document.getElementById('jsEn').innerHTML='';
</script>

HTH,

-Snib <><
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
  #3 (permalink)  
Old September 15th, 2004, 04:40 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi snib,

but how do i check if the javascript is enabled or not...

if it is disabled..the code u have given is never going to fire..so i can't use any javascript to check if javascript is enabled or disabled...propably i should do from the codebehind...

but i don't know how?

Thank You.



  #4 (permalink)  
Old September 15th, 2004, 09:40 PM
Registered User
 
Join Date: Sep 2004
Location: Shenzhen, GuangDong, China.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to heroman
Default

you can use the ASP.NET Object Request.Browser
example:
Add A <asp:Label id="msg" runat="server" /> on your page
then

public void Page_Load(object sender,EventArgs e)
{
if(!Request.Browser.JavaScript)
  {
   msg.Text="You must enable the Javascript";
  }
}

Study,Progress,Life...
  #5 (permalink)  
Old September 15th, 2004, 10:57 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

pran,

If the code doesn't fire, the text "Please enable JavaScript" will still display.

-Snib <><
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
  #6 (permalink)  
Old September 16th, 2004, 12:41 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

ok cool i will try that....

well it will always show enable javascript but that is not what i want i want it to display only when javascript is disabled...

thanks for trying though

have a good day

  #7 (permalink)  
Old September 16th, 2004, 04:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this instead:

<noscript>
Enable JavaScript!
</noscript>

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once.
  #8 (permalink)  
Old September 16th, 2004, 05:09 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

yep snib that worked..thanks alot man.

i don't know why Request.Browser.Javascript would still show true inspite of disabling the JavaScript for some reason...

but <noscript> works that's wonderful..

but all i want to do is..if javascript is not enabled i want the browser to pick an other page like javascripterror.html...

and i don't know how to do that ...

and when does Request.Browser.JavaScript actually show false bczit is true even after i disable scripting.

Thanks again snib.

Have a good day

  #9 (permalink)  
Old September 16th, 2004, 08:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey pran,

Redirecting to another page would look something like this:

<noscript>
<meta http-equiv='refresh' content='0;url=http://yoursite.com/yourdirectory/yourfile.htm'/>
</noscript>

HTH!

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once :-)
The Following User Says Thank You to Snib For This Useful Post:
gadget2fun (January 30th, 2013)
  #10 (permalink)  
Old September 17th, 2004, 01:04 PM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank You snib. that worked and it's wonderful.

Have a good weekend.

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net 2.0 and JavaScript zion22 Javascript How-To 0 September 28th, 2006 02:28 PM
asp.Net 2.0 and JavaScript zion22 ASP.NET 2.0 Professional 0 September 28th, 2006 02:10 PM
javascript in asp.net Komila Generics 0 August 3rd, 2006 02:24 AM
javascript to asp.net bimboypogi ASP.NET 1.0 and 1.1 Professional 2 March 21st, 2005 02:49 AM



All times are GMT -4. The time now is 11:10 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.