Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2004, 10:31 AM
Authorized User
 
Join Date: Sep 2004
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.


 
Old September 15th, 2004, 12:08 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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.
 
Old September 15th, 2004, 03:40 PM
Authorized User
 
Join Date: Sep 2004
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.



 
Old September 15th, 2004, 08:40 PM
Registered User
 
Join Date: Sep 2004
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...
 
Old September 15th, 2004, 09:57 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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.
 
Old September 16th, 2004, 11:41 AM
Authorized User
 
Join Date: Sep 2004
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

 
Old September 16th, 2004, 03:42 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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.
 
Old September 16th, 2004, 04:09 PM
Authorized User
 
Join Date: Sep 2004
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

 
Old September 16th, 2004, 07:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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:
 
Old September 17th, 2004, 12:04 PM
Authorized User
 
Join Date: Sep 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Have a good weekend.






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.