-
Set td to False
I wnat to make td to false and true on the master Page Load.
Code:
public partial class Templates_Deloitte : System.Web.UI.MasterPage
{
private bool m_LeftNavVisible = true;
protected void Page_Load(object sender, EventArgs e)
{
this.tdTree1.Visible = NavVisible;
this.divTree1.Visible = NavVisible;
}
public bool NavVisible
{
get
{
return this.m_LeftNavVisible;
}
set
{
this.m_LeftNavVisible = value;
}
}
SOURCE CODE--
Code:
<div id="divContent">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td runat="server" id="tdTree1" style="vertical-align: top; width: 0%; text-align: left;">
<div runat="server" id="divTree1" style="width: 250px; height: 600px; overflow: auto;
padding: 0px; margin: 0px;" class="gradient">
</div>
</td>
</tr>
</table>
</div>
I am getting the error
'Templates_Deloitte' does not contain a definition for 'tdTree1' and no extension method 'tdTree1' accepting a first argument of type 'Templates_Deloitte' could be found (are you missing a using directive or an assembly reference?)
When I run the Page & view source then
Code:
<div id="divContent">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="ctl00_tdTree1" style="vertical-align: top; width: 0%; text-align: left;">
<div id="ctl00_divTree1" style="width: 250px; height: 400px; overflow: auto;
padding: 0px; margin: 0px;" class="gradient">
From the SOurce Code
tdTree1 ---->ctl00_tdTree1
divTree1----> ctl00_divTree1
Can somebody tell me how to set visibility to True & False using Javascript on Master Page Load.
-
Re: Set td to False
Hello,
I am slightly confused by your post. Your code seems to suggest that you are trying to toggle the visibility of the control in your server side code, but then in your question, you say you want to toggle the visibility on the client side using JavaScript.
Which one is it?
The difficulty that you are having circles around the fact that the ClientID of the control is not the same and the server id. There is very good reason for this.
Gary
-
Re: Set td to False
hi gep sir, first tell me one thing tdTree1 ---->ctl00_tdTree1
which one is server id and which one is client id. I just want to set visibility of the control to true or false on the master page load,watever may be the method.
I used the below code at server side,but I m getting the error, as mentioned in my above Post.
Code:
this.tdTree1.Visible = NavVisible;
this.divTree1.Visible = NavVisible;
-
Re: Set td to False
The server id is "tdTree1" and the client id is "ctl00_tdTree1".
What is happening is since tdTree1 is contained within a container element, i.e. a table, ASP.Net tries to make sure that the id of the control on the client is always unique, hence it appends additional information on the front of the client id.
If you are trying to toggle the visibility on the client using JavaScript, you will need to use the ClientId, and if you are trying to set it on the server, you will need to use the Server ID.
As to why you are getting that error, I am not sure, I will need to do some digging.
Gary