In my MasterPage.Master I have this code:
<% if (Convert.ToBoolean(Session["FullVersion"])) { %>
<asp:LinkButton ID="LinkButton1" Text="Gå til mobilversjon" OnClick="GoToMobileVersion" runat="server" />
<% } %>
Instead of declaring this function in MasterPage.master.cs like this:
protected void GoToMobileVersion(object sender, EventArgs e)
{
PageBase page = (PageBase)Page;
page.Session["FullVersion"] = false;
Response.Redirect(Server.UrlPathEncode(page.CurrentPage.LinkURL));
}
I would like to do the declare the function in MasterPage.Master.
What syntax would I use to do this?
Here is what I want to do:
<%
protected void GoToMobileVersion ()
{
Session["FullVersion"] = false;
Server.TransferRequest(Request.Url.AbsolutePath, false);
}
%>
You can define functions with script runat=”server” block,
http://msdn.microsoft.com/en-us/library/f0111sbh(v=vs.100).aspx