When I press this link it will post back to my method. How can I do that?
<li runat="server" onclick="log_out" >
<a onclick="log_out" runat="server" href="LogIn.aspx" ><i class="icon_key_alt"></i> Log Out</a>
</li>
This is my method:
public void log_out(object sender, EventArgs e)
{
try
{
int employeeid = Convert.ToInt32(Session["employeeid"].ToString());
cl.log_out_activity(Convert.ToInt32(employeeid));
}
catch
{
}
}
What you have is a HyperLink
so you can set the NavigateUrl
like this:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~Login.aspx">HyperLink</asp:HyperLink>
Then in the Page_Load
of LogIn.aspx
you will do whatever you need to.
If you want to go to a specific method then use LinkButton
because it has OnClick
property like this:
<asp:LinkButton
ID="Button1"
OnClick="log_out"
runat="server"
Text="Submit" />
If you want to do go to a specific method with HyperLink
, you then have to use javascript. You can see this article on how to do it. Personally I would just use LinkButton
:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.