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 :-(