Reputation: 231
Table2 is invisible and i want to make it visible on click of Register Button.
<table>
<tr>
<td>
<asp:Button Id="btnstudent" runat="server" Text="Student Registraion" OnClick="btnstudent_Click"/>
</td>
<td>
<asp:Button ID="btnfees" runat="server" Text="Fees"/>
</td>
</tr>
</table>
<table ID="Table2" style="visibility:hidden">
<tr>
<td>
Name
</td>
<td> <asp:TextBox ID="nametxt" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
Contact No.
</td>
<td> <asp:TextBox ID="contacttxt" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
Course Name
</td>
<td> <asp:TextBox ID="coursetxt" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
Fees
</td>
<td> <asp:TextBox ID="feetxt" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
Address
</td>
<td> <asp:TextBox ID="Addresstxt" runat="server"></asp:TextBox></td>
</tr><tr>
<td>
<asp:Button ID="btnregister" runat="server" Text="Register"/>
</td>
</tr>
</table>
</asp:Content>
//On button Click
protected void btnstudent_Click(object sender, EventArgs e)
{
Table2.style.visibility="visible";
}
Getting Error
Table2 does not exist in current context.
Upvotes: 2
Views: 7606
Reputation: 1512
You need to set the runat property in your table to make it work
<table id="Table2" runat="server">
Change in your button click event
Table2.style.visibility="visible";
To
Table2.Visible = true; // to show
And use in your page load event
if (!IsPostBack)
{
Table2.Visible = false; // to hide
}
Upvotes: 2