views:

1198

answers:

3

I have a select checkbox that has invisible set to false. ASPX looks like this:

<input name="selGR" id="selGR" type="checkbox" checked="checked" visible="false" runat="server" fieldname="GR"/>

The select box is not even rendered in the HTML which explains why JQuery is not finding it. Is there a way around this?

EDIT: Setting style works! Thanks. I am curious to know if there are any rules the .NET framework follows when rendering controls with visible="false"? For all controls irrespective of whether they are server, custom or html controls, it follows this rule? Also, any side effects of setting the style instead of setting the property of visible?

+1  A: 

Use "style='display: none'" instead of "visible='false'". That way it will still be in the rendered HTML for JQuery to do something with.

Jonathan
+4  A: 

you can always set the display property to none. jQuery will be able to find it at that point.

<input type="checkbox" id="selGr" style="display:none" />

For future reference as well. $("#selGr").hide() & $("#selGr").show() basically uses the display property of the element.

I do not believe an 'visible' is an attribute of an element. There is visibility and display that can be set within the style attribute though. For a better understand of the difference between visibility and hidden check this out: http://www.devx.com/tips/Tip/13638

Dan Appleyard
Visible is an ASP property, usually on server controls. Setting it to false keeps the control from being rendered on the page. Don't confuse it with the style visibility attribute either.
tvanfosson
I meant on standard HTML elements (non ASP/.NET controls)
Dan Appleyard
+1  A: 

Visible is a asp.net attribute,by setting it to false is to ask sever not to render the control. That is why your check box is not in the html source code.

Chaning html display style property to none is telling the explorer not to display the checkbox, however, it is stilled included in the source code.

wschenkai