473,327 Members | 1,896 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,327 software developers and data experts.

conditional javascript in asp.net

I want to add a javascript which would execute only if certain
requirements are met.
Example:
If user isn't logged in, a message box would pop up, telling the user he
has to log in, but if the user is already logged in, there would be no message.

In classical asp, I would do it like this:

<body<% IF LEN(Session("username"))=0 THEN Response.Write " onLoad=""alert('You need to log in for more info!')""" %>>

How to do that in asp.net, using .vb code? I know how to add javascript events for controls, but not for the page body.
Sep 21 '06 #1
3 1263
You could use RegisterClientScript. Wrap the register around a
conditional to test if they are logged in. Here is a thread with an
example of how to use this:

http://groups.google.com/group/micro...f6aa687001c3b4

hope this helps!

Sean

Zdenko Rupcic wrote:
I want to add a javascript which would execute only if certain
requirements are met.
Example:
If user isn't logged in, a message box would pop up, telling the user he
has to log in, but if the user is already logged in, there would be no message.

In classical asp, I would do it like this:

<body<% IF LEN(Session("username"))=0 THEN Response.Write " onLoad=""alert('You need to log in for more info!')""" %>>

How to do that in asp.net, using .vb code? I know how to add javascript events for controls, but not for the page body.
Sep 21 '06 #2
Sean Chambers wrote:
You could use RegisterClientScript. Wrap the register around a
conditional to test if they are logged in. Here is a thread with an
example of how to use this:

http://groups.google.com/group/micro...f6aa687001c3b4

hope this helps!

Sean
It did, thanks.
Sep 22 '06 #3

Your welcome

Zdenko Rupcic wrote:
Sean Chambers wrote:
You could use RegisterClientScript. Wrap the register around a
conditional to test if they are logged in. Here is a thread with an
example of how to use this:

http://groups.google.com/group/micro...f6aa687001c3b4

hope this helps!

Sean

It did, thanks.
Sep 22 '06 #4

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

Similar topics

8
by: Guy Hocking | last post by:
Hi there, I am having a few problems compiling a list box that is conditional on what is selected in another list box. What i need is a List box (lstArea) that displays one thing when the List...
1
by: Orest Kinasevych | last post by:
Okay, I made sense of the earlier suggestions and realized I was on the right track -- I appreciate the feedback which got me to this point. The suggestions posted here indeed worked and...
10
by: Québec | last post by:
Hi every body, What does that mean? The following script raises the subject alarm. <p><a href="javascript:void();" onClick="mailto:sgagnon@cyberus.ca?Subject=BRITTANY&nbsp;WORKSHOP"> <img...
4
by: TheKeith | last post by:
I just wrote the following script for something I'm working on: ---------------------------------------------------------------------------- ------------------- <html> <head> <script...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
10
by: VK | last post by:
Taking into account many new features in JavaScript1.6 and JavaScript1.7 which are syntactically incompatible with Javascript versions run on other browsers: would it be reasonable to propose as...
4
by: Zack | last post by:
Hi, Let's say you have this function named validate. validate looks like this: function validate() { return ($F("Email") != '' ? ($("Name").value = $F("Email")) : false); }
4
by: rocketeer | last post by:
I've a set of Javascript classes that maintain state. For example, gm.js might be: var GroupManager { groups: {} }; Over time I add new groups to the list: GroupManager.groups = myGroup; ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.