Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all , how can i access invisible control using javascript such that
label
Posted

You have to use display style to handle it.

You cannot access invisible controls via javascript. Only those controls that are rendered on client site are available to javascript.

If a particular control is marked as Visible=false at server side, then that control is no more present in the HTML of the rendered page on client machine.

Though there is another way to handle such scenarios. If you need to hide a control but also want to access it in Javascript then play with style:display property.

Thus:
to hide the control
JavaScript
// javascript code
document.getElementById("<%=lblToHide.ClientID%>").style.display = "none";


to show the control
JavaScript
//javascript code
document.getElementById("<%=lblToHide.ClientID%>").style.display = "block";
 
Share this answer
 
v3
You can do that by following trick. Don't set visible="false" to your control, just use the style property(display) for the control.
example.
<input type="text" text="Hello" name="txtInvisible" style="display:none;" />

C#
alert(document.getElementById('txtInvisible').value)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900