0

如果page_load我正在检查授权是否Admin存在。

如果他们不在Admin角色中,那么我必须将可用asp:label控件更改asp:textbox为 UI 中的控件。

  1. 是否可以将控件动态转换/替换为asp:label控件asp:textbox

  2. 如果可以进行转换/替换,那么我可以在后面的代码中而不是使用 jQuery 来做吗?

<asp:Label ID="label1" runat="server" Text="Data">&nbsp;</asp:Label>
4

2 回答 2

0

Alternatively, you could mark the TextBox control read-only for non-admins and style the textbox accordingly:

if !User.IsInRole("Administrators")
{
    TextBox1.ReadOnly = true;
    TextBox1.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");  
    TextBox1.BorderWidth = Unit.Pixel(0);
}
于 2013-01-31T17:21:43.513 回答
0

您可以使用MultiViewASP.NET拥有两个views. 你将有一个label在一个viewtextbox另一个。

if (user == "admin")
  multiView1.SetActiveView(adminView)
else
  multiView1.SetActiveView(userView)

另一种解决方案是使用labelandtextbox并让页面相应地隐藏它们。

于 2013-01-31T16:12:23.890 回答