By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,953 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,953 IT Pros & Developers. It's quick & easy.

Partial Classes, .Net 2.0 and Custom Attributes

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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/aspne...n/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.


Nov 19 '05 #2

P: n/a
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/aspne...n/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.


Nov 19 '05 #3

P: n/a
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/aspne...n/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.


Nov 19 '05 #4

P: n/a
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/aspne...n/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.


Nov 19 '05 #5

P: n/a
Agreed.

Let me ask why the built-in localization scheme doesn't work for you? If
you need more control over it you can build your own expression builder such
that you get to define your own <%$ %> syntax in the pages. That would then
invoke your code to do your own conditional localization.....

-Brock
DevelopMentor
http://staff.develop.com/ballen
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/aspne...n/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.
>


Nov 19 '05 #6

P: n/a
Well, the problem is that I don't really want it to be tied to culture. So
it's not really localization in that sense, it's rather the ability to
provide alternative sets of terminology (which might include a separate
langyage altogether) So I might have two different sets of terminology being
used within the same culture setting. That's really why I thought that the
language localization infrastructure provided by the .Net framework didn't
quite fit.

I also need to store my resources in a database rather than resource files,
but I think .Net 2 allows that right?

"Brock Allen" wrote:
Agreed.

Let me ask why the built-in localization scheme doesn't work for you? If
you need more control over it you can build your own expression builder such
that you get to define your own <%$ %> syntax in the pages. That would then
invoke your code to do your own conditional localization.....

-Brock
DevelopMentor
http://staff.develop.com/ballen
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/aspne...n/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.
>>


Nov 19 '05 #7

P: n/a
Yeah, that's why I suggested looking into your own custom Expression Builders.
Sounds like that's a perfect fit for your needs.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Well, the problem is that I don't really want it to be tied to
culture. So it's not really localization in that sense, it's rather
the ability to provide alternative sets of terminology (which might
include a separate langyage altogether) So I might have two different
sets of terminology being used within the same culture setting. That's
really why I thought that the language localization infrastructure
provided by the .Net framework didn't quite fit.

I also need to store my resources in a database rather than resource
files, but I think .Net 2 allows that right?

"Brock Allen" wrote:
Agreed.

Let me ask why the built-in localization scheme doesn't work for you?
If you need more control over it you can build your own expression
builder such that you get to define your own <%$ %> syntax in the
pages. That would then invoke your code to do your own conditional
localization.....

-Brock
DevelopMentor
http://staff.develop.com/ballen
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/aspne...ion/default.as
>> px
>>
>> -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.
>>>


Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.