views:

8

answers:

1

Hi all,

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...

A: 

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
kbrimington
Yes you are right. It is easiest way. But i need to access its html code. I will delete or add something before it is posting to client.
uzay95