开发者

asp.net, enable/disable tabpanel

Why isn't this working?

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

While this w开发者_StackOverflow社区orks:

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


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");
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜