I have an html list to which I am trying to add html button to the property "innerhtml" using the code behind file. I am able to add the button however the onclick event is not getting fired
HTML:
<ul runat="server" id="list">
<li></li>
<li><a id="loginID" runat="server" href="../Accounts/login.aspx">Login</a></li>
<li id="logout" runat="server"> <a href="~/Register.aspx" runat="server"> Register</a></li>
</ul>
code behind:
logout.InnerHtml = "<input type=\"submit\" id=\"b1\" runat=\"server\" onserverclick=\"b1_click\" />"; //logout is the id of the list item
}
}
public void b1_click(Object sender,EventArgs e)
{
Response.Redirect("~/Accounts/login.aspx");
}
}