Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 8 Jul 2008 06:46:36 -0700 (PDT),    group: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       


Rich Textbox Problem   
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?
date: Tue, 8 Jul 2008 06:46:36 -0700 (PDT)   author:   wolfgang

Re: Rich Textbox Problem   
Hi wolfgang

>    public class MyTextBox : TextBox
>    {
>        protected override void Render(HtmlTextWriter writer)
>        {
>            base.Render(writer);
>            LinkButton button = new LinkButton();
>            button.Text = "Button";
>            button.RenderControl(writer);
>        }
>    }
Should work.
But be sure to give the control a ID.

What is the produced Output looks like?

-- 
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
date: Wed, 9 Jul 2008 13:11:16 +0200   author:   Peter Bucher [MVP]

Re: Rich Textbox Problem   
On 9 Jul., 13:11, "Peter Bucher [MVP]" 
wrote:
> Hi wolfgang
>
> >    public class MyTextBox : TextBox
> >    {
> >        protected override void Render(HtmlTextWriter writer)
> >        {
> >            base.Render(writer);
> >            LinkButton button = new LinkButton();
> >            button.Text = "Button";
> >            button.RenderControl(writer);
> >        }
> >    }
>
> Should work.
> But be sure to give the control a ID.
>
> What is the produced Output looks like?
>
> --
> 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
date: Thu, 10 Jul 2008 23:36:29 -0700 (PDT)   author:   wolfgang

Re: Rich Textbox Problem   
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);
        }
    }

-- 
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
date: Fri, 11 Jul 2008 13:15:59 +0200   author:   Peter Bucher [MVP]

Re: Rich Textbox Problem   
On 11 Jul., 13:15, "Peter Bucher [MVP]" 
wrote:
> 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);
>         }
>     }
>
> --
> 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
date: Fri, 11 Jul 2008 05:25:17 -0700 (PDT)   author:   wolfgang

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us