开发者

asp.net, enable/disable tabpanel

开发者 https://www.devze.com 2022-12-27 06:50 出处:网络
Why isn\'t this working? <ajaxToolkit:TabPanel Enabled=\'<%# User.IsInRole(\"admin\") %>\'...

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

精彩评论

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

关注公众号