开发者

Finding html element onPreRender state of User Control

开发者 https://www.devze.com 2023-01-15 05:26 出处:网络
I have a user control which has html elements like <input type=\"button\".... and i want to set its display property开发者_如何转开发 on preRender state.

I have a user control which has html elements like <input type="button".... and i want to set its display property开发者_如何转开发 on preRender state.

Would you please explain, what kind things i have to handle this user control? So, in this function protected override void OnPreRender(EventArgs e) { } I have only EventArgs e and it doesn't have proper method or properties to bring me the html of user control.

Thank you from now...


The easiest way to control visibility of elements from the server side is to promote them to server controls. For example:

<input id="mybutton" runat="server" type="button" ...

Doing so would allow you to execute a statement like the following in your OnPreRender() event:

mybutton.Visible = false; // removes the element

Or...

mybutton.Style[HtmlTextWriterStyle.Display] = "none"; // styles the element
0

精彩评论

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

关注公众号