Display: Custom Control

Posted by pipelinecache on Stack Overflow See other posts from Stack Overflow or by pipelinecache
Published on 2010-05-09T14:11:56Z Indexed on 2010/05/09 14:18 UTC
Read the original article Hit count: 317

Hi folks, I've made a simple custom control:

base.Style[HtmlTextWriterStyle.Position] = "absolute";

            if (this.Expanded) // If the Calendar is expanded.
                this.Style[HtmlTextWriterStyle.Display] = "block";
            else
                this.Style[HtmlTextWriterStyle.Display] = "none";

            //create the containing table
            Panel pnl = new Panel();
  pnl.ID = "pnl_" + this.ClientID;
            pnl.Enabled = true;           


            SherlockIIITextBox txtCalendar = new SherlockIIITextBox();                
            txtCalendar.ID = "Cal_" + this.ClientID;

            pnl.Controls.Add(txtCalendar);

            ImageButton imgButton = new ImageButton();
            imgButton.ImageUrl = "";
            imgButton.ID = "img_" + this.ClientID;
            imgButton.BorderStyle = BorderStyle.NotSet;
            imgButton.OnClientClick = "o = document.getElementById('" + this.ClientID + "');if (o.style.display=='none'){o.style.display='block';}else{o.style.display='none';}";
            pnl.Controls.Add(imgButton);
            pnl.RenderControl(writer);

When I click the ImageButton it should render the calendar. But when I click the ImageButton nothing happens.

Anyone got an idea?

© Stack Overflow or respective owner

Related posts about c#

Related posts about JavaScript