Overclockers Australia Forums
OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Software Topics > Programming & Software Development

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 13th September 2002, 7:49 PM   #1
xsive Thread Starter
Member
 
xsive's Avatar
 
Join Date: Jun 2001
Location: Sydney
Posts: 4,202
Default [ASP/VBScript] Redirecting Problems

I want to create an ASP page with a button that will redirect me to another page.
My problem is that "Response.Redirect()" seems to be a server-side object and can't be called from a client-side script/subroutine.
The result being, I cant use onClick= to call a redirect.

I've tried several different things, my latest effort being below

Code:
<%@Language=VBscript%>
<%Response.Buffer=True%>

<html>
<body>

<% Public Sub RedirectMe
	    Response.Redirect("vote.asp?Validate=No")
   End Sub
%>	

<INPUT TYPE=BUTTON name="btnMine" VALUE="No" onClick="<%Call RedirectMe %>">
  
</body>
</html>
It makes no difference if i change "Call RedirectMe" to RedirectMe().
Can anyone suggest a possible solution?
I've done a bit of a workaround where i use a button/form combo to redirect me to the desired page and while it works its not what I want.

Any tips much appreciated
__________________
Quote:
Originally Posted by Lucifers Mentor View Post
Oooh! Oooh! Can I be evil and German? PPPPLLlleeeaassseeeeeeeeee??!!!???
xsive is offline   Reply With Quote

Join OCAU to remove this ad!
Old 14th September 2002, 11:49 AM   #2
mpot
<blank>
 
mpot's Avatar
 
Join Date: Jun 2001
Location: Perth, WA
Posts: 5,345
Default

That's never going to work, because you're using client-side scripting (the button onClick) to call server-side scripting (the RedirectMe sub).

You need to do it all with client-side scripting, because once the page has been loaded into the client browser, the ASP scripting cannot be accessed anymore....it's only executed when the web server is building the page.

This will work:
Code:
<input type="button" value="No" onClick="javascript:top.location.href='vote.asp?Validate=No'">
Cheers,
Martin.
__________________
[ photography blog | redbubble | flickr ]
mpot is offline   Reply With Quote
Old 14th September 2002, 1:06 PM   #3
xsive Thread Starter
Member
 
xsive's Avatar
 
Join Date: Jun 2001
Location: Sydney
Posts: 4,202
Default

Hi mpot,

Thanks for pointing me in the right direction. I went searching for the VBS alternative to JS' top.location.href and managed to get it working.

__________________
Quote:
Originally Posted by Lucifers Mentor View Post
Oooh! Oooh! Can I be evil and German? PPPPLLlleeeaassseeeeeeeeee??!!!???

Last edited by xsive; 14th September 2002 at 1:28 PM.
xsive is offline   Reply With Quote
Old 19th September 2002, 12:22 PM   #4
Snickers
Member
 
Snickers's Avatar
 
Join Date: Apr 2002
Location: Brisbane
Posts: 86
Default

If you were to use the new asp.net then you would be able to use server side scripting. I'm only just new at it but i believe it would work something like this.

---------------------------------------------------------------------------------
<script language="VBSCript" runat="Server">

sub RedirectMe(byval pWhere)
response.redirect pWhere
end sub

</script>

<input type="button" value="Go Now" onclick="RedirectMe 'http://gosomewherenow.com'">


---------------------------------------------------------------------------------

I'm not really sure if that would work i was just trying to demonstrate the advantages of .net. I actually don't think you can use the response.redirect anymore

There is another way of redirecting with vbscript (client side)

---------------------------------------------------------------------------------
<script language="vbScript">

sub RedirectMe(byval pWhere)
window.self.location = pWhere
end sub

</script>

<input type="button" value="Go with vbScript" onclick="vbScript:RedirectMe 'Http://gosomewherenow.com'">
---------------------------------------------------------------------------------

I just thought i would give you a bit more infor and options. When doing client side scripting events like the onclick above. If you need to use both vbScript and Javascript on your page you will need to specify (as i have done) which language to use.

Snickers is offline   Reply With Quote
Old 19th September 2002, 12:23 PM   #5
Ch00k
Member
 
Ch00k's Avatar
 
Join Date: Aug 2002
Location: Melbourne
Posts: 1,404
Default

AFAIK, you would need "runat=server" on the input tag for that to work. ASP.NET needs to know that you want it to be a server event, not client.
__________________
-- Chicken
Ch00k is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

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

Forum Jump


All times are GMT +10. The time now is 10:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. -
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Internode!