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 / General / October 2007

Tip: Looking for answers? Try searching our database.

Custom Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 31 Oct 2007 15:53 GMT
Hello,

I have a custom control named Parent where I used the following:

   Protected Overrides Sub CreateChildControls()
     ...

     MyBase.Controls.Add(MyTextBox)
     MyBase.CreateChildControls()
     Me.ChildControlsCreated = True
   End Sub

   Public Overloads Overrides Sub RenderBeginTag(ByVal writer As
HtmlTextWriter)
     If Me.ClientID <> Nothing Then _
       writer.AddAttribute(HtmlTextWriterAttribute.Id, Me.ClientID)
     If Me.CssClass <> Nothing Then _
       writer.AddAttribute(HtmlTextWriterAttribute.Class,
Me.CssClass)
     writer.RenderBeginTag(HtmlTextWriterTag.Div)
   End Sub

   Public Overloads Overrides Sub RenderEndTag(ByVal writer As
HtmlTextWriter)
     writer.RenderEndTag()
   End Sub

Now I created a new control named Child which inherits from Parent.

In this control I need to do two things:

1. Add a new control, a label.

2. Make CssClass = "MyChildCssClass" IF Me.CssClass = Nothing.

I am having problems with making this happen.

I tried to create CreateChildControls and RenderBeginTag in my Child
control that inherits from my Parent control but something is going
on.

I am not able to "merge" the control adding and attributes from my
Parent control and my Child control.

How should I do this?

Thanks,

Miguel
shapper - 31 Oct 2007 17:30 GMT
> Hello,
>
[quoted text clipped - 45 lines]
>
> Miguel

Hi,

Basically I have the following:

 Public Class Parent
   Inherits WebControl
   Implements INamingContainer

   Protected Overrides Sub CreateChildControls()
   ...
   End Sub ' CreateChildControls

   Public Overloads Overrides Sub RenderBeginTag(ByVal writer As
HtmlTextWriter)
   ...
   End Sub ' RenderBeginTag

   Public Overloads Overrides Sub RenderEndTag(ByVal writer As
HtmlTextWriter)
   ...
   End Sub ' RenderEndTag

And:

 Public Class Child
   Inherits Parent

In Child I need to also add controls and define attributes as it is
done in CreateChildControls and RenderBeginTag of Parent.
For example:
 Add TextBox1 in Parent and TextBox2 in child
 Define Width attribute in Parent and CssClass in child.

Until now I wasn't able to do this. I did a few changes in overload
and overriding of those methods but I wasn't able to make this work.

How can I do this?

Thanks,
Miguel
jx.su.go@gmail.com - 31 Oct 2007 17:36 GMT
> Hello,
>
[quoted text clipped - 45 lines]
>
> Miguel

I think you missing the key 'base'.
if you want to use the parent method. you should call the base method.
shapper - 31 Oct 2007 18:08 GMT
On Oct 31, 4:36 pm, "jx.su...@gmail.com" <jx.su...@gmail.com> wrote:

> > Hello,
>
[quoted text clipped - 48 lines]
> I think you missing the key 'base'.
> if you want to use the parent method. you should call the base method.

Sorry, I got lost now :-(

Rate this thread:







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.