The onclick attribute of your anchor tag will call the client function. (This is what you would use if you would like to call the javascript function when the link is clicked.)
What you want is a server control, such as LinkButton :
<asp:LinkButton ID="lnkTutorial" runat="server" Text="Tutorial" OnClick="displayTutorial_Click"/>
This has an onclick attribute that will call the method in your code.
Looking further at your code, it looks like you're just trying to open another tutorial based on the user's access level. You do not need an event handler for this. The best thing would be to simply set the endpoint of your LinkButton control in code.
protected void Page_Load(object sender, EventArgs e) { userinfo = (UserInfo)Session["UserInfo"]; if (userinfo.user == "Admin") { lnkTutorial.PostBackUrl = "help/AdminTutorial.html"; } else { lnkTutorial.PostBackUrl = "help/UserTutorial.html"; } }
In fact, it would be better to verify that you actually have a user.
protected void Page_Load(object sender, EventArgs e) { if (Session["UserInfo"] != null && ((UserInfo)Session["UserInfo"]).user == "Admin") { lnkTutorial.PostBackUrl = "help/AdminTutorial.html"; } else { lnkTutorial.PostBackUrl = "help/UserTutorial.html"; } }
source share