Be seen. Boost your question’s priority for more expert views and faster solutions
if(!isuserinrole())
{
foreach (Control ctl in this.Controls)
{
ctl.EnableViewState = true;
DisableControl(ctl);
ctl.RenderControl(writer);
}
}
private void DisableControl(Control control)
{
if (control is WebControl)
{
((WebControl)control).EnableViewState = true; //((WebControl)control).Enabled = false;
((WebControl)control).Attributes.Add("disabled", "disabled");
}
else if (control is HtmlControl)
((HtmlControl)control).Attributes.Add("Disabled", "True");
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
it works fine. it may be helpful for other users when they really need this functionality.