tanaya80
asked on
How do i hide a table row in asp.net web application
i am hiding a row of a table using javascript function in asp.net page .here, i m using a check box , when i ll checked the checkbox , it will hide the row , and when i ll un checked it will show the row, but i m getting problem when i am submitting the data by onclick button event the row is showing.means
when the checkbox is checked means it will hide the row.but when i m submitting the data on Onclick event of the button the row is visible,means when the page is postback that time the row is visible.so i m getting problem.plz help me urgently.
when the checkbox is checked means it will hide the row.but when i m submitting the data on Onclick event of the button the row is visible,means when the page is postback that time the row is visible.so i m getting problem.plz help me urgently.
<body>
<input id="Checkbox1" onClick="toggle()" type="checkbox" />
<table border="1">
<tr>
<td>Always visible</td>
</tr>
<tr id="hidethis" runat="server">
<td>Hide this</td>
</tr>
<tr>
<td>Always visible</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</body>
</html>
<script language="javascript" type="text/jscript">
function toggle()
{
if( document.getElementById("hidethis").style.display=='none' )
{
document.getElementById("hidethis").style.display = 'block';
return true;
}else{
document.getElementById("hidethis").style.display = 'none';
return false;
}
}
</script>
ASKER
ok this is working fine in page level, but when i m using in .acx page means in a webcontrol or in a gridview then it is not working bcz how i will define the <body onload="to toggle()"> , is there any alternative solution.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window