Re: Partial Classes, .Net 2.0 and Custom Attributes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yes that's an idea I could try. It all starts to get a bit laborious then.

"Brock Allen" wrote:

> The only other thing I could suggest is making a property on your page which
> sets the text on the Label and then aoontate thge property w/ your custom
> attribute.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Thanks for the response. I have looked into the Asp 2 localization
> > model and it doesn't quite do what I want it to.
> >
> > It seems like a bit of a problem that it is impossible to add an
> > attribute to a control added declaratively in design view. I can't
> > believe there's no way to do it. I do want to do things the 2005 way
> > in every other regard because it's easier and better.
> >
> > "Brock Allen" wrote:
> >
> >> If you need to add a custom attribute to the field, then don't use
> >> partial classes and the new CodeFile directive. I think you're going
> >> to have a struggle though, as the new VS.NET model doesn't want to do
> >> things the old way :)
> >>
> >> BTW, since your attribute is called [Localize] I'm wondering if the
> >> new localization model in 2.0 will suit your needs:
> >>
> >> http://beta.asp.net/QUICKSTART/aspnet/doc/localization/default.aspx
> >>
> >> -Brock
> >> DevelopMentor
> >> http://staff.develop.com/ballen
> >>> Hi,
> >>>
> >>> I had an aspx pag in .Net 1.1 with a label on it. As such I had a
> >>> code behind page with a declaration for that label.
> >>>
> >>> When I convert to Asp.Net 2.0 the code behind is converted to a
> >>> partial class and the declaration for the label is removed. This is
> >>> what I expected to happen and I understand why it has happened.
> >>>
> >>> The problem I have is that I had added a custom attribute to my
> >>> label declaration which I use to handle localization. e.g.
> >>>
> >>> [Localize]
> >>> protected System.Web.UI.WebControls.Label lScreenTitle;
> >>> Since that declaration has been removed, so has the custom
> >>> attribute.
> >>> My question is, how do you add a custom attribute to a control on an
> >>> aspx page in Asp.Net 2.0 given that you no longer have access to the
> >>> control's declaration in the code-behind file?
> >>>
> >>> Thanks,
> >>>
> >>> Julian Jelfs.
> >>>
>
>
>
>
.