[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Adding an attribute to an existing control

Ricky

1/7/2003 6:19:00 PM

Hi,

I am trying to add an attribute to an existing control. So far I have
created a class that inherits the radiobutton control. Added a property to
the control that contains the following code in the set...

base.Attributes.Add("summary", value);


This gives me a span tag (that contains the summary attribute) around my
input tag. I was hoping to get my attribute into the input tag. Can someone
help me by pointing me in the right direction on how this is done?

Thank you all in advance for your help!!!

Ricky


4 Answers

Ajay

1/8/2003 3:52:00 AM

0

protected override void AddAttributesToRender(HtmlTextWriter writer)
{

writer.AddAttribute("myAtt", "myVal");
base.AddAttributesToRender(writer);

}

HTH,
Ajay

"Ricky" <forthespammers@nodomaintogiveyou.com> wrote in message
news:OmgScDntCHA.2532@TK2MSFTNGP10...
> Hi,
>
> I am trying to add an attribute to an existing control. So far I have
> created a class that inherits the radiobutton control. Added a property to
> the control that contains the following code in the set...
>
> base.Attributes.Add("summary", value);
>
>
> This gives me a span tag (that contains the summary attribute) around my
> input tag. I was hoping to get my attribute into the input tag. Can
someone
> help me by pointing me in the right direction on how this is done?
>
> Thank you all in advance for your help!!!
>
> Ricky
>
>


Ricky

1/8/2003 6:17:00 PM

0

That gives me the same result. Since the radiobutton has two elements to its
result, the input tag and label tag, could it be possible that the
radiobutton class does not know which tag to add the attribute to? If that
is the case, how does one get at the different tags to manipulate them? I've
tried...

base.Controls[0].*

BUT! during the render method, the base object doesn't have any controls in
it and it also doesn't have any methods at that point in the hierarchy to
add an attribute. Is there a way to add my attribute to a specific tag in
the control?

Thanks,
Ricky

"Ajay" <ajayb@nospam.grapecity.com> wrote in message
news:#Evv3DstCHA.1816@TK2MSFTNGP10...
> protected override void AddAttributesToRender(HtmlTextWriter writer)
> {
>
> writer.AddAttribute("myAtt", "myVal");
> base.AddAttributesToRender(writer);
>
> }
>
> HTH,
> Ajay
>
> "Ricky" <forthespammers@nodomaintogiveyou.com> wrote in message
> news:OmgScDntCHA.2532@TK2MSFTNGP10...
> > Hi,
> >
> > I am trying to add an attribute to an existing control. So far I have
> > created a class that inherits the radiobutton control. Added a property
to
> > the control that contains the following code in the set...
> >
> > base.Attributes.Add("summary", value);
> >
> >
> > This gives me a span tag (that contains the summary attribute) around my
> > input tag. I was hoping to get my attribute into the input tag. Can
> someone
> > help me by pointing me in the right direction on how this is done?
> >
> > Thank you all in advance for your help!!!
> >
> > Ricky
> >
> >
>
>


Ajay

1/9/2003 2:10:00 AM

0

Ricky,
The default implementation of webcontrol's Render does this :
1) Calls RenderBeginTag()
2) Calls RenderContents()
3) Then calls RenderEndTag()

Now all the attributes you have added to the attributes collection are
rendered
when RenderBeginTag is called (xml element is created and the attributes in
the collection are added to the element).
What this means in your scenario is that probably the RadioButton's
RenderBeginTag is creating the outside span tag so all the attributes are
added to the span. Now the inner input tag might be getting creaeted in
RenderContents. You could try overriding the RenderContents and before
calling the base.RenderContents add your attributes.

protected override RenderContents(HtmlTextWriter writer) {
writer.AddAttribute("myAtt", "myVal");
base.RenderContents(writer);
}

If even this doesn't work then send me your code and I will try & look for a
fix.

Ajay (mailto:ajayb@grapecity.com)


"Ricky" <forthespammers@nodomaintogiveyou.com> wrote in message
news:#J1qSnztCHA.2540@TK2MSFTNGP10...
> That gives me the same result. Since the radiobutton has two elements to
its
> result, the input tag and label tag, could it be possible that the
> radiobutton class does not know which tag to add the attribute to? If that
> is the case, how does one get at the different tags to manipulate them?
I've
> tried...
>
> base.Controls[0].*
>
> BUT! during the render method, the base object doesn't have any controls
in
> it and it also doesn't have any methods at that point in the hierarchy to
> add an attribute. Is there a way to add my attribute to a specific tag in
> the control?
>
> Thanks,
> Ricky
>
> "Ajay" <ajayb@nospam.grapecity.com> wrote in message
> news:#Evv3DstCHA.1816@TK2MSFTNGP10...
> > protected override void AddAttributesToRender(HtmlTextWriter
writer)
> > {
> >
> > writer.AddAttribute("myAtt", "myVal");
> > base.AddAttributesToRender(writer);
> >
> > }
> >
> > HTH,
> > Ajay
> >
> > "Ricky" <forthespammers@nodomaintogiveyou.com> wrote in message
> > news:OmgScDntCHA.2532@TK2MSFTNGP10...
> > > Hi,
> > >
> > > I am trying to add an attribute to an existing control. So far I have
> > > created a class that inherits the radiobutton control. Added a
property
> to
> > > the control that contains the following code in the set...
> > >
> > > base.Attributes.Add("summary", value);
> > >
> > >
> > > This gives me a span tag (that contains the summary attribute) around
my
> > > input tag. I was hoping to get my attribute into the input tag. Can
> > someone
> > > help me by pointing me in the right direction on how this is done?
> > >
> > > Thank you all in advance for your help!!!
> > >
> > > Ricky
> > >
> > >
> >
> >
>
>


Martin R. Legnoverde

1/10/2003 7:06:00 PM

0

Hi,
Do you know if it's possible to disable a propert afeter changing other
property? I am talking about design-time. For example:

- MyWebControl - Prop. A: XXX
- MyWebControl - Prop. B: 123

If Prop A is changed at design time to YYY, I would like that Prop. B will
be disabled. (Gray-style)

Regards,
Martin


"Ricky" <forthespammers@nodomaintogiveyou.com> wrote in message
news:OmgScDntCHA.2532@TK2MSFTNGP10...
> Hi,
>
> I am trying to add an attribute to an existing control. So far I have
> created a class that inherits the radiobutton control. Added a property to
> the control that contains the following code in the set...
>
> base.Attributes.Add("summary", value);
>
>
> This gives me a span tag (that contains the summary attribute) around my
> input tag. I was hoping to get my attribute into the input tag. Can
someone
> help me by pointing me in the right direction on how this is done?
>
> Thank you all in advance for your help!!!
>
> Ricky
>
>