Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute Server Side Script ??

Status
Not open for further replies.

vikramonline

Programmer
Oct 14, 2003
186
IN
I need to set a variable and redirect a user like
Session("Validate") = False
response.redirect "login.asp"
when a button is clicked . Do i need a server side or a client side script for this.

Any code will help.I am new to this script world.

Thanx
 
You need javascript

<script language=javascript>
function changepage(){
location.href=&quot;somepage.asp&quot;}
</script>

<input type=button value=&quot;Click Me&quot; onclick=changepage()>

 
Thanx GaryC123,
What abt the varaible : Session(&quot;Validate&quot;) = False
It has to be set on the server whereas the script will execute on the client.

I have got a solution
<a href = &quot;page1.asp&quot;>Click Me</a>
And in that page I write
Session(&quot;Validate&quot;) = False
response.redirect &quot;login.asp&quot;

But I want it to work using a script.
 
Vikramonline

That's the way it has to be done. For your knowledge you should know that asp variables can be passed to JavaScript functions but not in the other way. Lets say you have a public page where you can download a file only if you are loggeg in then you can use JavaScript as GaryC123 wrote you with asp variables in it

Function Download()
{
var ok = <% =Session(&quot;Validate&quot;) %>
if (ok)
{
document.location.href = &quot;&quot;
}
else
{
alert('Please login')
document.location.replace = &quot;login.asp&quot;
}
}
 
Thanx All,

One more thing I would like to ask.

What I am doing is I have made an entry into global.asa file like this
Session(&quot;Validate&quot;) = False (This is outside any script)

And when the user logs in successfully I make
Session(&quot;Validate&quot;) = True

And when the user logs off I make
Session(&quot;Validate&quot;) = False

Is everthing that I am doing OK .Any suggestions


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top