473,484 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

asp 2.0 menu and javascript

Does anyone know how to access the menu items from javascript. I can
use the onclick to perform an action but I would like to be
enable/disable items based on page status.

Thanks
Ken
Nov 19 '05 #1
4 1280
This would best be done from the CodeBehind. While you can do it with
JavaScript on the client-side, you may get unexpected results on the
server-side.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Ken Nipper" <ke*@fngservices.com> wrote in message
news:Lq********************@giganews.com...
Does anyone know how to access the menu items from javascript. I can
use the onclick to perform an action but I would like to be
enable/disable items based on page status.

Thanks
Ken

Nov 19 '05 #2
Kevin Spencer wrote:
This would best be done from the CodeBehind. While you can do it with
JavaScript on the client-side, you may get unexpected results on the
server-side.


Would you mind explaining. My goal is to enable/disable menu items
based on page state without causing a postback to the server.
Nov 19 '05 #3
Hi Ken,
Would you mind explaining.
ASP.Net is built to run in a stateless HTTP environment. The client is
unaware of the server, and the server is unaware of the client. That is the
nature of HTTP, which is really a messaging protocol. The client sends a
Request to a web server for a specific resource (URL). The client Request is
a text message with headers that include a bit of information about the
client (IP address, browser type, etc) and the message itself. The server
receives the Request and processes it, returning the Response, which is
typically an HTML document, or some binary file. The server is unaware of
the client, and only has the single Request message to work with in
preparing the Response.

The ASP.Net object model is designed to emulate state by a rather
sophisticated collection of work-arounds, such as the server posting
JavaScript and hidden form fields containing state information to the
client, so that the client-side, server-generated JavaScript, together with
the form's POST contents (including the hidden form fields, such as
ViewState and Event-related fields) can REMIND the server of what part of
what conversation the client may be continuing (in a PostBack).

So, using JavaScript on the client that is not generated by the server can
have unexpected results, as it may bypass or override the ASP.Net
object-model's mechanisms for passing information back and forth between the
client and server.

That said, I believe you can do what you want to do, but keep this in mind
if, in the future, you see something unexpected as a result of client-side
JavaScript form manipulation. For example, changing the value of form fields
programmatically, may or may not be recognized by the server-side Page
class, although you can usually circumvent this by using the Request.Form
Collection separtely from the built-in event-handling mechanisms.

In this case, you're not modifying anything in any form fields, but just
showing and hiding them. Keep in mind, however, that if the user changes
their mind after filling in a form field, and then hides it, this doesn't
remove the value from the POST. Just some cautionary advice. Measure twice,
cut once!

The following link is to a tutorial on this subject that may be helpful to
you:

http://www.devx.com/webdev/Article/10483/1954?pf=true

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Ken Nipper" <ke*@fngservices.com> wrote in message
news:yt********************@giganews.com... Kevin Spencer wrote:
This would best be done from the CodeBehind. While you can do it with
JavaScript on the client-side, you may get unexpected results on the
server-side.


Would you mind explaining. My goal is to enable/disable menu items
based on page state without causing a postback to the server.

Nov 19 '05 #4
Thanks! That was exactly what I was looking for.

Thanks again
Ken

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4648
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
4
3813
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
8
3235
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
10
2004
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
4
5744
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
2
3846
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
3
2081
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can...
4
2299
torquehero
by: torquehero | last post by:
Hi all :) I have created a horizontal navbar using Xara Menumaker. The Menu items have several dropdown menus. Its a javascript. When the mouse cursor is moved over any menu item, a dropdown...
2
4152
by: dharmbhav | last post by:
Hello all, I am trying to develop a roll-over menu effect on a page. It works fine with all other browsers except IE6. Can some one please help me? HTML: <div class="menu-item-wrap">...
0
7082
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4845
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4529
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3046
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
592
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
235
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.