473,785 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript alert function

Hi,

In a document I have three lines that detects and
redirects to another page is a session variable is 0

If Session("Custom er_ID")=0 Then
Response.Redire ct("myPage.aspx ")
End If

What I really would like to have is a notification for the
users what happened before they were redirected and in
traditional asp I used the javascript alert function, but
how does the code go to implement this in asp.net above
the line Response.Redire ct("myPage.aspx ")?

TIA

/Kenneth
Nov 17 '05 #1
2 2883
You have to be mindful of where your code is running when you are using
ASP.NET. In your example, since you are using the Session object, you are
running on the server. Your web server has no way of popping up an alert
dialog on the user's machine. Instead, it has to write JavaScript code to
the client, which can then execute this code and give the user an alert. So,
you need to change your approach. If you need the alert, you will need to
feed the information to the client, and have the entire check take place
there, in which case you lose access to your session variable (stored on the
server), so the only comparison you will be able to do is based on something
on that form or else something that you write out to the client machine.

If you want to get clever, it's also possible that you could redirect to a
new page that serves the same purpose as the alert - giving them a button to
proceed with the redirect, and a button that just executes a history.back
script to bring the user back to the previous page.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kenneth" <ke***********@ chello.se> wrote in message
news:09******** *************** *****@phx.gbl.. .
Hi,

In a document I have three lines that detects and
redirects to another page is a session variable is 0

If Session("Custom er_ID")=0 Then
Response.Redire ct("myPage.aspx ")
End If

What I really would like to have is a notification for the
users what happened before they were redirected and in
traditional asp I used the javascript alert function, but
how does the code go to implement this in asp.net above
the line Response.Redire ct("myPage.aspx ")?

TIA

/Kenneth

Nov 17 '05 #2
Chris,

With all respect, in an oldfashioned .asp file I have the
following code:

<% if Session("UserNa me") = "" then %>
<script language="javas cript">
alert('Session Timeout has expired. You
have to log in again!');
top.location.hr ef = "login.asp" ;
</script>
<% end if%>

It also runs on the server.

Can't I use the Page 'RegisterStartu pScript' method to
achive the same effect?

/Kenneth
-----Original Message-----
You have to be mindful of where your code is running when you are usingASP.NET. In your example, since you are using the Session object, you arerunning on the server. Your web server has no way of popping up an alertdialog on the user's machine. Instead, it has to write JavaScript code tothe client, which can then execute this code and give the user an alert. So,you need to change your approach. If you need the alert, you will need tofeed the information to the client, and have the entire check take placethere, in which case you lose access to your session variable (stored on theserver), so the only comparison you will be able to do is based on somethingon that form or else something that you write out to the client machine.
If you want to get clever, it's also possible that you could redirect to anew page that serves the same purpose as the alert - giving them a button toproceed with the redirect, and a button that just executes a history.backscript to bring the user back to the previous page.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kenneth" <ke***********@ chello.se> wrote in message
news:09******* *************** ******@phx.gbl. ..
Hi,

In a document I have three lines that detects and
redirects to another page is a session variable is 0

If Session("Custom er_ID")=0 Then
Response.Redire ct("myPage.aspx ")
End If

What I really would like to have is a notification for the users what happened before they were redirected and in
traditional asp I used the javascript alert function, but how does the code go to implement this in asp.net above
the line Response.Redire ct("myPage.aspx ")?

TIA

/Kenneth

.

Nov 17 '05 #3

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

Similar topics

0
7073
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass simple/advanced html forms and how it can be used to override cookie/session
1
2707
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff working, but it only worked for IE. You can see a working version here: http://www.publicpen.com/designer/mcControlPanel.php username: designer password: designer123 However, I've tried to rewrite this so it would work in all browsers,
11
1644
by: Vincent van Beveren | last post by:
Hi everyone, I have the following code using inheritence The important part is the function getName(). The result should alert 'John Doe': function First(name) { this.name = name; this.getName = function() { return this.name;
14
5486
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
5
25855
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the function...if that makes sense. Here's what I mean... I have a javascript array set up like so: <script language="javascript" TYPE="text/JavaScript"> //custom object constructor
1
3533
by: Jing You | last post by:
hi every one, I have got some confused problem when I try to write some custom object by javascript. Look at the example code here: <BODY> <script language="jscript">
9
4923
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
7
3228
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the column need to be a date picker field. I know things will be easier with ASPX datagrid.
1
25700
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that variable can only be used in that function. If you were to try to access that variable anywhere else in...
12
8924
by: pantagruel | last post by:
Hi, I'm thinking of making a WScript based JavaScript library, I can think of some specific non-browser specific scripting examples that should probably make it in, like Crockford's little JavaScripter, can anyone think of anything else. Is anyone familiar with anything similar already done. Things that I am thinking that to provide are:
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9952
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8976
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.