473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1278
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
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
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
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
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
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
2
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.