Question

Why isn't this working?

<ajaxToolkit:TabPanel Enabled='<%# User.IsInRole("admin") %>'...

While this works:

<asp:TextBox Enabled='<%# User.IsInRole("admin") %>'...
Was it helpful?

Solution

Is the first example within a binding context (bound control)? Perhaps you want to use the output directive instead of the binding directive?

<ajaxToolkit:TabPanel Enabled='<%= User.IsInRole("admin") %>'

EDIT: My bad. <%= %> translates into Response.Write, which is not what you want -- too used to ASP.NET MVC, I guess. The best thing is to make it runat="server", give it an ID and set the value in your code-behind.

<ajaxToolkit:TabPanel runat="server" ID="myTabs" ... />


protected void Page_Load( object sender, EventArgs e )
{
    myTabs.Enabled = User.IsInRole("admin");
    ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top