473,385 Members | 1,872 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,385 software developers and data experts.

custom resource manager in ASP.NET 2.0

Hi,

is it possible to implement custom resource managers for ASP.NET 2.0 so
that strings can be read from a database (for example)?

Ideally, it should be possible to configure the custom resource manager
in web.config, so that it replaces the default resource manager. Using
the <%$ ... %> syntax should read the strings via the custom resource
manager, e.g. when used like this:
<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
Thanks for any help,
Martin
Nov 19 '05 #1
5 2588
Martin,

I have done this in one of my project. I created an extended resource
manager which gets the strings file from the xml rather getting it from the
compiled resource, so it is possible, that you can extend the asp.net
resource manager according to your requirement.

--
Wajahat Abbas
http://www.dotnetpakistan.com
http://www.wajahatabbas.com
"Martin Bischoff" wrote:
Hi,

is it possible to implement custom resource managers for ASP.NET 2.0 so
that strings can be read from a database (for example)?

Ideally, it should be possible to configure the custom resource manager
in web.config, so that it replaces the default resource manager. Using
the <%$ ... %> syntax should read the strings via the custom resource
manager, e.g. when used like this:
<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
Thanks for any help,
Martin

Nov 19 '05 #2
Hi Martin,

Welcome to ASP.NET newsgroup.
Regarding on the asp.net 2.0 resource manager question you mentioned,
based on my understanding, this is not available in the comming 2.0 versino
of the ASP.NET. Since the <%$ %> expression are translated to the actual
code/statements at compile time, this translation is fixed in the compiler,
we won't be able to customize it with our own type. Currently I think we
may consider use the <%# %> databinding experssion with out own custom
class or function to retrieve the resource as we like.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Date: Wed, 31 Aug 2005 09:19:53 +0200
| From: Martin Bischoff <ni******@newsgroup.nospam>
| User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: custom resource manager in ASP.NET 2.0
| Content-Type: text/plain; charset=ISO-8859-1; format=flowed
| Content-Transfer-Encoding: 7bit
| Message-ID: <OP**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 194.209.202.1
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP09.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121351
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
|
| is it possible to implement custom resource managers for ASP.NET 2.0 so
| that strings can be read from a database (for example)?
|
| Ideally, it should be possible to configure the custom resource manager
| in web.config, so that it replaces the default resource manager. Using
| the <%$ ... %> syntax should read the strings via the custom resource
| manager, e.g. when used like this:
|
|
| <asp:Label ID="Label1" runat="server"
| Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
|
|
| Thanks for any help,
| Martin
|

Nov 19 '05 #3
Yes, these can be customized. They're called expression builders. I posted
in the past month an example, but here's another:

using System.Web.Compilation;
using System.CodeDom;

public class AppSettExBld : ExpressionBuilder
{
public static string GetVal(string param)
{
return System.Web.Configuration.WebConfigurationManager.A ppSettings[param];
}
public override System.CodeDom.CodeExpression GetCodeExpression(BoundPropertyEntry
entry, object parsedData, ExpressionBuilderContext context)
{
CodeMethodInvokeExpression ex = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(AppSettExBld)),
"GetVal", new CodePrimitiveExpression(entry.Expression.ToString( ).Trim()));
return ex;
}
}
The method you should customize is GetVal. This sample simply reads from
<appSettings> but you could read from a database. To configure you need to
modify the <compilation> section in web.config:

<compilation debug="true" defaultLanguage="C#">
<expressionBuilders>
<add expressionPrefix="AppSet" type="AppSettExBld, __code"/>
</expressionBuilders>
</compilation>
And now you can use <%$ AppSett:SomeKeyToTheGetValMethod %> in your ASPX
pages.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

is it possible to implement custom resource managers for ASP.NET 2.0
so that strings can be read from a database (for example)?

Ideally, it should be possible to configure the custom resource
manager in web.config, so that it replaces the default resource
manager. Using the <%$ ... %> syntax should read the strings via the
custom resource manager, e.g. when used like this:

<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
Thanks for any help,
Martin


Nov 19 '05 #4
Thanks a lot for both Wajahat and Brock's informative suggestions.

Seems I've really missed such a great feature. I'll keep this in mind and
have some further investigate in the
asp.ne whidbey.

Thanks again for your contribution.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Message-ID: <11***********************@msnews.microsoft.com>
| From: Brock Allen <ba****@NOSPAMdevelop.com>
| Subject: Re: custom resource manager in ASP.NET 2.0
| References: <OP**************@TK2MSFTNGP09.phx.gbl>
| Mime-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 469.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Wed, 31 Aug 2005 21:19:41 -0700
| NNTP-Posting-Host: 12.162.27.25
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP11.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121612
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Yes, these can be customized. They're called expression builders. I
posted
| in the past month an example, but here's another:
|
| using System.Web.Compilation;
| using System.CodeDom;
|
| public class AppSettExBld : ExpressionBuilder
| {
| public static string GetVal(string param)
| {
| return
System.Web.Configuration.WebConfigurationManager.A ppSettings[param];
| }
| public override System.CodeDom.CodeExpression
GetCodeExpression(BoundPropertyEntry
| entry, object parsedData, ExpressionBuilderContext context)
| {
| CodeMethodInvokeExpression ex = new CodeMethodInvokeExpression(new
CodeTypeReferenceExpression(typeof(AppSettExBld)),
| "GetVal", new
CodePrimitiveExpression(entry.Expression.ToString( ).Trim()));
| return ex;
| }
| }
|
|
| The method you should customize is GetVal. This sample simply reads from
| <appSettings> but you could read from a database. To configure you need
to
| modify the <compilation> section in web.config:
|
| <compilation debug="true" defaultLanguage="C#">
| <expressionBuilders>
| <add expressionPrefix="AppSet" type="AppSettExBld, __code"/>
| </expressionBuilders>
| </compilation>
|
|
| And now you can use <%$ AppSett:SomeKeyToTheGetValMethod %> in your ASPX
| pages.
|
| -Brock
| DevelopMentor
| http://staff.develop.com/ballen
|
|
|
| > Hi,
| >
| > is it possible to implement custom resource managers for ASP.NET 2.0
| > so that strings can be read from a database (for example)?
| >
| > Ideally, it should be possible to configure the custom resource
| > manager in web.config, so that it replaces the default resource
| > manager. Using the <%$ ... %> syntax should read the strings via the
| > custom resource manager, e.g. when used like this:
| >
| > <asp:Label ID="Label1" runat="server"
| > Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
| > Thanks for any help,
| > Martin
|

|
|

Nov 19 '05 #5
Thanks to everyone. In the meantime I have also found out about expression
builders, and these allow me to do what I want.

I have also read about ResourceProviderFactory, IResourceProvider and
IResourceReader. But I did not find a way to configure ASP.NET to use my
custom resource manager instead of the default one (at least for strings).

Regards,
Martin

Brock Allen wrote:
Yes, these can be customized. They're called expression builders. I
posted in the past month an example, but here's another:

using System.Web.Compilation;
using System.CodeDom;

public class AppSettExBld : ExpressionBuilder
{
public static string GetVal(string param)
{
return
System.Web.Configuration.WebConfigurationManager.A ppSettings[param];
}
public override System.CodeDom.CodeExpression
GetCodeExpression(BoundPropertyEntry entry, object parsedData,
ExpressionBuilderContext context)
{
CodeMethodInvokeExpression ex = new
CodeMethodInvokeExpression(new
CodeTypeReferenceExpression(typeof(AppSettExBld)), "GetVal", new
CodePrimitiveExpression(entry.Expression.ToString( ).Trim()));
return ex;
}
}
The method you should customize is GetVal. This sample simply reads from
<appSettings> but you could read from a database. To configure you need
to modify the <compilation> section in web.config:

<compilation debug="true" defaultLanguage="C#">
<expressionBuilders>
<add expressionPrefix="AppSet" type="AppSettExBld,
__code"/>
</expressionBuilders>
</compilation>
And now you can use <%$ AppSett:SomeKeyToTheGetValMethod %> in your ASPX
pages.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

is it possible to implement custom resource managers for ASP.NET 2.0
so that strings can be read from a database (for example)?

Ideally, it should be possible to configure the custom resource
manager in web.config, so that it replaces the default resource
manager. Using the <%$ ... %> syntax should read the strings via the
custom resource manager, e.g. when used like this:

<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Resource, STRING_ID %>"></asp:Label>
Thanks for any help,
Martin


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brad | last post by:
Hi all, newbie here. I'm currently designing a custom splitter control... When the mouse hovers over a certain area on my splitter I need to be able to display a custom cursor that I've designed....
6
by: Peter Oliphant | last post by:
I've now asked how three times in this forum with no answers. So I went to the 'windowsforms' newsgroup, and found this post, also unanswered, with the same problem: "Hello, I've tried to...
1
by: Tom | last post by:
This may seem a little strange, but in all my years of developing Windows Forms apps, I've never really used Resource files; however, I would like to start doing so in order to store icons,...
4
by: bern11 | last post by:
How do you embed a custom cursor? The help says: // On the command line: // Add the following flag: // /res:CursorFileName.Cur,Namespace.CursorFileName.Cur What if you are...
0
by: ramesh.nrk | last post by:
Hi, I am developing a windows application which should support different language for this I am using "Resource Manager" default in .net framework. Here I am developing dll for Resource because...
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
1
by: =?Utf-8?B?V29ua28gdGhlIFNhbmU=?= | last post by:
Hello, I have a custom control, and want to derive a second control from that control. public class CustomButton : Button { } public class SpecialCustomButton : CustomButton
0
harshadd
by: harshadd | last post by:
Dear all, I am trying to install File server Resource Manager to apply user level directory quota. Tried to use this link for help , it is as below: I checked the GIF file But on my...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.