prog rice bowl
prog rice bowl

Reputation: 778

Classic ASP Redirect URL using variable

I have a variable tag <%test_variable%> that was from a resultset.

I want to use this <%=test_variable%> to redirect to a link, say

http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok

How can I do this in the <% %> tag? For example,

<%=test_variable%> 

<%
' I want to redirect the url with the above tag, something like:

Response.Redirect(" http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok")
%>

But I don't think we can have "nested tags", right?

I'm pretty new to ASP.

Upvotes: 2

Views: 7864

Answers (3)

prog rice bowl
prog rice bowl

Reputation: 778

Thanks all for your suggestions...

I've decided to use this instead:

<script type="text/javascript">
   window.location =  "http://www.helloworld.someurl.com/testUrl?somevariable="+<%=test_variable%>+"&test=ok"
</script>

Upvotes: 1

stealthyninja
stealthyninja

Reputation: 10371

Your code should be

Response.Redirect("http://www.helloworld.someurl.com/testUrl?somevariable=" & test_variable & "&test=ok")

Upvotes: 1

Alex
Alex

Reputation: 35409

<%= %> is shorthand for <% Response.Write(" ... "); %>:

http://www.helloworld.someurl.com/testUrl?somevariable=<%=test_variable%>&test=ok

After your clarification:

<%
    Response.Redirect("http://www.helloworld.someurl.com/testUrl?somevariable="
                     + test_variable
                     + "&test=ok");
%>

Upvotes: 3

Related Questions