Server side .Visible is not the same as the client side visibilty attribute. When you set .Visible =false on the server side the control is not even sent to the client at all, it won't even be in the HTML.
To set the client side visibilty property from server side you can do like this:
txt1.Style[HtmlTextWriterStyle.Visibility] = value;