Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > page redirection

Reply
Thread Tools

page redirection

 
 
Paul
Guest
Posts: n/a
 
      07-11-2008
Hi all,

This will hopefully be a really simple question....

I'm a newbie at web app development, and am teaching my self as I go. I have
a page that requires a user to click a
button which then pops up a message box asking the user to make a choice.
Based on this choice, it will either redirect to another page or display a
message. I can get it to display a message, but when it tries to redirect I
get the error;

"Error: Object doesn't support this property or method: 'document.redirect'"

I have tried researching this error but cannot find a solution that works,
can anyone help?

The page code is as follows;

<form>
<INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">

<SCRIPT LANGUAGE="VBScript" >
Sub button_2_onclick
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.write("answer = ")&answer
Else If answer = "7" Then
document.redirect="test2.html"
Else if answer = "2" then
exit sub
End If
End If
End If
End Sub
</SCRIPT>

</form>

Many thanks in advance

Paul

 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      07-11-2008
Hi all,

sorry to waste your time, I have resolved it myself!!

Changed this line:-
document.redirect="test2.html"
To this:-
document.location.href="test2.html"

thanks again!

"Paul" <> wrote in message
news201461F-C97B-4573-B5C3-...
> Hi all,
>
> This will hopefully be a really simple question....
>
> I'm a newbie at web app development, and am teaching my self as I go. I
> have a page that requires a user to click a
> button which then pops up a message box asking the user to make a choice.
> Based on this choice, it will either redirect to another page or display a
> message. I can get it to display a message, but when it tries to redirect
> I get the error;
>
> "Error: Object doesn't support this property or method:
> 'document.redirect'"
>
> I have tried researching this error but cannot find a solution that works,
> can anyone help?
>
> The page code is as follows;
>
> <form>
> <INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">
>
> <SCRIPT LANGUAGE="VBScript" >
> Sub button_2_onclick
> answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
> sheet")
> If answer = "6" then
> document.write("answer = ")&answer
> Else If answer = "7" Then
> document.redirect="test2.html"
> Else if answer = "2" then
> exit sub
> End If
> End If
> End If
> End Sub
> </SCRIPT>
>
> </form>
>
> Many thanks in advance
>
> Paul
>


 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      07-11-2008
Ok, after sayng i'm good, i find i'm not!!

Heres the thing....

I have page 1 which has a form on it. when a button is clicked, it passes
the data from the form onto page 2. Thats easy (even for me!), but after
page 2 loads, I need it to popup a message box asking the user to make a
choice and redirect to another page based on the response. When the page
redirects I need it to redirect using values already bought into the page
but cannot pass the values into the script (if that makes sense) Heres how i
have the code on page 2....

<%@ LANGUAGE=VBScript %>
<%Response.Buffer = True%>

<%
Dim var1, var2 and other connection vars

Set objConnString = Server.CreateObject("ADODB.Connection")
Set rs1 = Server.CreateObject("ADODB.Recordset")
strDSN = "provider=sqloledb;Data Source=BARCA;Initial
Catalog=JellyTracker;User Id=sa;Password=LpmMww2502;"
objConnString.Open strDSN

jtuser = request("user") --> this value is passed via the url string
callres = request("callres") --> this value is collected from the previous
pages form
callnum = request("callnum")--> this value is passed via the url string
closedby = request("closedby") --> this value is collected from the previous
pages form
closetype = request("closetype") --> this value is collected from the
previous pages form
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
</style></head>
<body>
<SCRIPT LANGUAGE="VBScript" >
answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
sheet")
If answer = "6" then
document.redirect.href="page3.asp?callnum=<%=calln um%>&callres=<%=callres%>"
Else If answer = "7" Then
document.redirect.href="page1.asp?callnum=<%=calln um%>&callres=<%=callres%>"
End If
End If

</SCRIPT>
</body>
</html>

Within the <script> tags, i cannot get the variables <%=callnum%> or
<%=callres%> (or anything else) to show their values, and am completely
stumped, outside the tags, I can see and manipulate them any way I want.

Am I being a bit of a plank here? Is there an easy way for me to do this?

Any help would be appreciated.

Thanks in advance

Paul

"Paul" <> wrote in message
news:C3DAA96C-76C2-428D-BE47-...
> Hi all,
>
> sorry to waste your time, I have resolved it myself!!
>
> Changed this line:-
> document.redirect="test2.html"
> To this:-
> document.location.href="test2.html"
>
> thanks again!
>
> "Paul" <> wrote in message
> news201461F-C97B-4573-B5C3-...
>> Hi all,
>>
>> This will hopefully be a really simple question....
>>
>> I'm a newbie at web app development, and am teaching my self as I go. I
>> have a page that requires a user to click a
>> button which then pops up a message box asking the user to make a choice.
>> Based on this choice, it will either redirect to another page or display
>> a message. I can get it to display a message, but when it tries to
>> redirect I get the error;
>>
>> "Error: Object doesn't support this property or method:
>> 'document.redirect'"
>>
>> I have tried researching this error but cannot find a solution that
>> works, can anyone help?
>>
>> The page code is as follows;
>>
>> <form>
>> <INPUT TYPE="BUTTON" NAME="button_2" VALUE="Click Here!">
>>
>> <SCRIPT LANGUAGE="VBScript" >
>> Sub button_2_onclick
>> answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
>> sheet")
>> If answer = "6" then
>> document.write("answer = ")&answer
>> Else If answer = "7" Then
>> document.redirect="test2.html"
>> Else if answer = "2" then
>> exit sub
>> End If
>> End If
>> End If
>> End Sub
>> </SCRIPT>
>>
>> </form>
>>
>> Many thanks in advance
>>
>> Paul
>>

>


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      07-11-2008
"Paul" <> wrote in message
news:C73CE4A2-D7E3-4180-9AE7-...
> Ok, after sayng i'm good, i find i'm not!!
>
> Heres the thing....
>
> I have page 1 which has a form on it. when a button is clicked, it passes
> the data from the form onto page 2. Thats easy (even for me!), but after
> page 2 loads, I need it to popup a message box asking the user to make a
> choice and redirect to another page based on the response. When the page
> redirects I need it to redirect using values already bought into the page
> but cannot pass the values into the script (if that makes sense) Heres how

i
> have the code on page 2....
>
> <%@ LANGUAGE=VBScript %>
> <%Response.Buffer = True%>
>
> <%
> Dim var1, var2 and other connection vars
>
> Set objConnString = Server.CreateObject("ADODB.Connection")
> Set rs1 = Server.CreateObject("ADODB.Recordset")
> strDSN = "provider=sqloledb;Data Source=BARCA;Initial
> Catalog=JellyTracker;User Id=sa;Password=LpmMww2502;"


I really hope that isn't the real password and its not a good idea to use
the sa account for any of this work. Create a Logon on the SQL server
specifically for this application. Store the connection string and other
utility functions (such as OpenConnection) in an .asp file that your other
files include.

> objConnString.Open strDSN
>
> jtuser = request("user") --> this value is passed via the url string
> callres = request("callres") --> this value is collected from the previous
> pages form
> callnum = request("callnum")--> this value is passed via the url string
> closedby = request("closedby") --> this value is collected from the

previous
> pages form
> closetype = request("closetype") --> this value is collected from the
> previous pages form
> %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title></title>
> <style type="text/css">
> </style></head>
> <body>
> <SCRIPT LANGUAGE="VBScript" >
> answer=MsgBox ("Call Sheet", vbYesNoCancel, "Click Yes to create a call
> sheet")
> If answer = "6" then
>

document.redirect.href="page3.asp?callnum=<%=calln um%>&callres=<%=callres%>"
> Else If answer = "7" Then
>

document.redirect.href="page1.asp?callnum=<%=calln um%>&callres=<%=callres%>"
> End If
> End If
>
> </SCRIPT>
> </body>
> </html>
>
> Within the <script> tags, i cannot get the variables <%=callnum%> or
> <%=callres%> (or anything else) to show their values, and am completely
> stumped, outside the tags, I can see and manipulate them any way I want.
>
> Am I being a bit of a plank here? Is there an easy way for me to do this?
>
> Any help would be appreciated.
>


Are you sure your client are only every going to use IE? Since your just
starting off would it not be better to ensure that your code is more
compatible with other browsers. Personally I'd target IE and FF for
intranet style apps.

What happens when the users press No or Cancel? How do you inform the user
what will happen if the press those buttons?

Basically having dialogs pop-up as part of UIs nominal flow is poor design.
Why not have a interceeding page that displays a confirmation of the
previous forms field entries that then has 3 buttons "Create Call Sheet",
"What ever 'No' would do", "Return to some starting point".

Alternatively have the first page have two buttons "Create Call Sheet",
"What ever no does". The destination page draws which ever form is
appropriate where both forms have a "Get me out here" button.


--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      07-11-2008
Paul wrote:
> Hi all,
>
> sorry to waste your time, I have resolved it myself!!
>
> Changed this line:-
> document.redirect="test2.html"
> To this:-
> document.location.href="test2.html"


You should use window.location instead of document.location.
document.location is not part of any standard, while there is at least a
working draft that describes window.location:
http://www.w3.org/TR/Window/#location

See also:

"document.location was originally a read-only property, although Gecko
browsers allow you to assign to it as well. For cross-browser safety,
use window.location instead."

http://developer.mozilla.org/en/docs...ument.location

In any case, you can see for yourself that .redirect is not a method of
*any* DOM object:
http://msdn.microsoft.com/en-us/libr...53(VS.85).aspx




--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


 
Reply With Quote
 
Old Pedant
Guest
Posts: n/a
 
      07-11-2008
Works just fine for me.

I have to guess/assume that you don't *REALLY* have any values in your
Request collection.

I created this simple page that I named "junk.asp":

*********** file: junk.asp ************
<%
callnum = Request("callnum")
%>
<HTML><BODY>
<SCRIPT LANGUAGE="VBScript" >
answer = MsgBox ("Click YES to create a call sheet", vbYesNoCancel, "Call
Sheet")
Select Case answer
Case 6 : page = "page3"
Case 7 : page = "page1"
Case Else : page = "invalidChoice"
End Select
location.href = page & ".asp?callnum=<%=callnum%>"
</SCRIPT>
</body>
</html>
**************** end of file **************

Then I invoked the page using
http://localhost/junk.asp?callnum=331188

And, indeed, I got to any of the three pages ("page1.asp", "page2.asp" or
"invalidChoice.asp" with the callnum parameter in place in the query string.
As expected.

So... Cockpit error on your part???

Time for debug???

<%
callnum = request("callnum")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<style type="text/css">
</style></head>
<body>
DEBUG: Callnum from request was <%=callnum%><HR>

<SCRIPT LANGUAGE="VBScript" >
....
</SCRIPT>
</body>
</html>

Put in DEBUG output of all those values you *THINK* you are getting from the
Request. Maybe you aren't?
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      07-14-2008
Well, thanks very much for all your responses.

Err, no thats not my sa username and password, (well not anymore! Cant
believe i left those in there!)

I think I'll be heading down the line of creating additional pages to
complete the task that I need.

Thanks again

Paul

"Old Pedant" <> wrote in message
news:C882E1EF-4778-42B4-8AF3-...
> Works just fine for me.
>
> I have to guess/assume that you don't *REALLY* have any values in your
> Request collection.
>
> I created this simple page that I named "junk.asp":
>
> *********** file: junk.asp ************
> <%
> callnum = Request("callnum")
> %>
> <HTML><BODY>
> <SCRIPT LANGUAGE="VBScript" >
> answer = MsgBox ("Click YES to create a call sheet", vbYesNoCancel, "Call
> Sheet")
> Select Case answer
> Case 6 : page = "page3"
> Case 7 : page = "page1"
> Case Else : page = "invalidChoice"
> End Select
> location.href = page & ".asp?callnum=<%=callnum%>"
> </SCRIPT>
> </body>
> </html>
> **************** end of file **************
>
> Then I invoked the page using
> http://localhost/junk.asp?callnum=331188
>
> And, indeed, I got to any of the three pages ("page1.asp", "page2.asp" or
> "invalidChoice.asp" with the callnum parameter in place in the query
> string.
> As expected.
>
> So... Cockpit error on your part???
>
> Time for debug???
>
> <%
> callnum = request("callnum")
> %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
> <title></title>
> <style type="text/css">
> </style></head>
> <body>
> DEBUG: Callnum from request was <%=callnum%><HR>
>
> <SCRIPT LANGUAGE="VBScript" >
> ...
> </SCRIPT>
> </body>
> </html>
>
> Put in DEBUG output of all those values you *THINK* you are getting from
> the
> Request. Maybe you aren't?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Page "Redirection" Ryan Moore ASP .Net 1 10-01-2004 08:49 PM
Page redirection history Tim Marsden ASP .Net 4 06-10-2004 02:35 AM
Page redirection by clicking image button. Phoebe. ASP .Net 1 02-27-2004 10:23 AM
Redirection and resume page execution Alex ASP .Net 0 01-20-2004 06:07 AM
Maintaining session and auth. ticket from page to page redirection Thomas Fujita ASP .Net Mobile 1 10-22-2003 06:56 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57