Results 1 to 4 of 4

Thread: Set td to False

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    474

    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.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    474

    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;

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width