Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / July 2008

Tip: Looking for answers? Try searching our database.

Rich Textbox Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wolfgang - 08 Jul 2008 14:46 GMT
I'd like to create a rich textbox which inherits from TextBox:

   public class MyTextBox : TextBox
   {
       protected override void Render(HtmlTextWriter writer)
       {
           base.Render(writer);
           LinkButton button = new LinkButton();
           button.Text = "Button";
           button.RenderControl(writer);
       }
   }

But in the output produced the linkbutton is no longer a LinkButton
but just plain text. If i inherit from CompositeControl everything
woks find but then my testbox is no longer a TextBox.

Is there a way to make my linkbutton work and my textbox remains a
TextBox?
Peter Bucher [MVP] - 09 Jul 2008 12:11 GMT
Hi wolfgang

>    public class MyTextBox : TextBox
>    {
[quoted text clipped - 6 lines]
>        }
>    }
Should work.
But be sure to give the control a ID.

What is the produced Output looks like?

Signature

Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

wolfgang - 11 Jul 2008 07:36 GMT
On 9 Jul., 13:11, "Peter Bucher [MVP]" <peter.buc...@aspnetzone.de>
wrote:
> Hi wolfgang
>
[quoted text clipped - 17 lines]
> Gruss, Peter Bucher
> Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerlandhttp://www.aspnetzone.de/- ASP.NET Zone, die ASP.NET Communityhttp://www.aspnetzone.de/blogs/peterbucher/- Auf den Spuren von .NET

Hi Peter,

the output produced is a TextBox and the text of the button. The
functionality of the LinkButton is lost. It's just text and not a
link.

Wolfgang
Peter Bucher [MVP] - 11 Jul 2008 12:15 GMT
Hi Wolfgang

Do it like so:
   public class MyTextBox : TextBox
   {
protected override void OnInit(.....) {
LinkButton b = new LinkButton();
b.ID = "someID";
b.Text = "someText";
this.Controls.Add(b);
}
       protected override void Render(HtmlTextWriter writer)
       {
           base.Render(writer);
           button.RenderControl(writer);
       }
   }

Signature

Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

wolfgang - 11 Jul 2008 13:25 GMT
On 11 Jul., 13:15, "Peter Bucher [MVP]" <peter.buc...@aspnetzone.de>
wrote:
> Hi Wolfgang
>
[quoted text clipped - 17 lines]
> Gruss, Peter Bucher
> Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerlandhttp://www.aspnetzone.de/- ASP.NET Zone, die ASP.NET Communityhttp://www.aspnetzone.de/blogs/peterbucher/- Auf den Spuren von .NET

Many thaks, Peter. The control is working, now. The source code now
is:

   public class MyTextBox : TextBox
   {
       protected override void OnInit(EventArgs e)
       {
           LinkButton button = new LinkButton();
           button.Text = "Button";
           this.Controls.Add(button);
       }
       protected override void Render(HtmlTextWriter writer)
       {
           base.Render(writer);
           base.RenderChildren(writer);
       }
   }

Wolfgang

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.