473,583 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.W ebControls.Labe l 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 1734
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.W ebControls.Labe l 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.W ebControls.Labe l 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.W ebControls.Labe l 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.W ebControls.Labe l 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.W ebControls.Labe l 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.W ebControls.Labe l 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.W ebControls.Labe l 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
2508
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. I.e. do we have to need to write:
10
2422
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 load as a 3rd partial class. This would be handy so i can generate standard code into one of the partial classes, while having my custom code...
5
1995
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" Gpa="3.50"> <Person Id="1" FirstName="FirstName0" LastName="LastName0" MiddleInitial="W"/> </Student> In my code, person is the base class and...
15
2140
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 have an attribute which can be applied to a class definition of a class which inherits from a base, mustinherit class. I want to define methods in the...
3
2568
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, do I need to point out all the codefiles in the page directive, or just one of them is enough?
1
2133
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 can examine to figure out what is left to be done in my application. The attribute is coded thusly: AttributeUsage((AttributeTargets.Class |...
3
1479
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
2556
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 able to programmatically control at runtime which properties are displayed. I've looked at the System.Windows.Forms.Design.ControlDesigner, and...
5
1972
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 business logic layer is decorated using the <System.ComponentModel.DataObject()> attributes and they are used to bind to controls and Object...
0
7896
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8328
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8195
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6581
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5375
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3820
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1434
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.