I'm trying to call a method written in the back from a div in the front
front:
<div runat="server" id="headerLink" onclick="headerLinkOnClick" style="cursor: pointer;">
<header>
</header>
</div>
back:
protected void headerLinkOnClick(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Roles.DeleteCookie();
Session.Clear();
Response.Redirect("~/default.aspx");
}
I must miss something but no idea what.
CodePudding user response:
You can achieve this with a hidden button
<asp:Button runat="server" id="btnPostback" style="display:none" onclick="headerLinkOnClick" />
<div onclick="document.getElementById('<%= btnPostback.ClientID %>').click()">Clickable DIV</div>