I'm trying to set a multiview control to the right view by calling a method from the code behind, which returns the value 0, but it won't return anything.
I have created a test method, which won't work:
MasterPage.aspx
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex='<%# test() %>'>
<asp:View ID="LoginPnl" runat="server">
<a href="Login.aspx">Log ind</a>
</asp:View>
<asp:View ID="LogoutPnl" runat="server">
<a href="#">Min side</a>
<a href="#">Log ud</a>
</asp:View>
</asp:MultiView>
MasterPage.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class landrupdans : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected int test()
{
return 0;
}
}
I hope someone can tell me, if it is possible at all to call methods from masterpages since it worked on another page.
One thing you need to do:
2. Declare the method as public.This code worked for me: