473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Partial Classes, .Net 2.0 and Custom Attributes

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
7 1723
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gomaw Beoyr | last post by:
Two question about the "partial classes" (in the next wersion of ..NET). Question 1 ========== Will partial classes (in the next version of C#) have to be declared "partial" in ALL places. ...
10
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and...
5
by: Chris Szabo | last post by:
Good afternoon everyone. I'm running into a problem deserializing a stream using the XmlSerializer. A stored procedure returns the following from SQL Server: <Student StudentId="1" Status="1"...
15
by: Jeff Mason | last post by:
Hi, I'm having a reflection brain fog here, perhaps someone can set me on the right track. I'd like to define a custom attribute to be used in a class hierarchy. What I want to do is to...
3
by: Lau Lei Cheong | last post by:
A few quick questions: Is there a limitation on how much partial class files we can have for a single class? And can a ASP.NET page file inherit a class from multiple code-behind files? if so,...
1
by: hardieca | last post by:
Hi! I decorate my unfinished classes and methods with a custom TODO attribute (as in things To Do). Using reflection, I am then able to parse through my classes and output all TODOs to a list I...
3
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
Just curios to know why a vb class is referred to as partial class. Especially after adding this item to your project. Thanks for any clarifications.
5
by: Jon Pope | last post by:
I've got a class which contains properties. I can supply this class to the Properties control, and it will properly display the properties and allow the user to edit them, etc. I would like to be...
5
by: SAL | last post by:
Hello, I would like to be able to set the WHERE clause of a select statement on the fly. I have a DataAccess layer designed using the DataSet designer and a BusinessLogic layer using classes. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.