ASP.NET Problem

  • Thread starter Thread starter Xarky
  • Start date Start date
X

Xarky

Hi,

I have the following piece of code. In reality it is a menu which has
more options. The main idea was taken from the following link.

http://msdn.microsoft.com/library/d...ta/html/OfficeFrontPageCreateDropDownMenu.asp


<table class="navbar" width="100%">
<tr>
<td class="menuNormal" width="20%">
<p>Sign out</p>
</td>
</tr>
</table>

On the sign out option I require an onmousedown() event, that when
fires, does the following operations.

{
Session["UserID"] = "";
Response.Redirect(...to login page);
}


Can someone help me doing it.
Thanks in Advance
 
onmousedown is a client side event. You can't have server side code firing
on a client side event, unless there is client side code to call the server.

In general, asp.net questions should be asked in the aspnet forum.
 
You could use javascript to redirect to a page
that handles the logout.
It is also possible to do it on the server side.
Web controls such as LinkButton, support Click event.
But then you'll have to populate the menu on the server side.
 
Hi

I tried it with the following code, and it worked. But is this the
correct way to do it?

<a href=Login.aspx onmousedown="<% Session["UserID"] = "";%>">
 
No it doesn't work.
This line logs the user out, every time the page is accessed.
You really need a better understanding of client / server programming.
Try this:
<a href="Logout.aspx" >Logout</a>
Logout.aspx should contain this line: Session["UserID"] = "";
 
Back
Top