MVC - Local Resource / Attempting To Override The DisplayNameAttribute?
Jan 17, 2010
I am having an issue when attempting to override the DisplayNameAttribute in ASP.NET MVC to provide a localized string. The code itself is straightforward and similar to that in another Stackoverflow post link text
The code works for global resources but not so well for local resources. I have a registration screen and used the Visual Studio "Generate Local Resource" command to create my local resource file. The generated file is named Registration.aspx.resx and the App_LocalResources folder is created relative to the actual Registration.aspx page - as one would expect.
However, when I attempt to get the localized string using:
ResourceManager.GetString(resourceKey)
I receive the following error message.
Could not find any resources
appropriate for the specified culture
or the neutral culture. Make sure
"FullAssemblyName.Views.Account.App_LocalResources.Registration_aspx.resources"
was correctly embedded or linked into
assembly "FullAssemblyName" at compile
time, or that all the satellite
assemblies required are loadable and
fully signed.
Using reflector, I can see that the file is actually Registration.aspx.resources and not Registration_aspx.resources - the underscore/period being the subtle difference
FullAssemblyName.Views.Account.App_LocalResources.Registration.aspx.resources
I have toyed with the code quite a bit but no matter what I do, the file being requested is always different than that copiled in the assembly. For instance, if i rename Registration_aspx (in the generated Registration.aspx.designer.cs class i get the same error but this time the path is "...App_LocalResources.Registrationaspx.resources"
Has anyone run into this? Is there any way I can ensure that the resource found in my assembly has this underscore?
View 1 Replies
Similar Messages:
Sep 22, 2010
When I run the application using the Web Developer it works fine. However when I run it using local IIS I get the following error:
The resource class for this page was not found. check if the resource file exists and try again. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The resource class for this page was not found. heck if the resource file exists and try again.
Source Error:
Line 81: private void PopulateLanguageList()
Line 82: {
Line 83: DropDownListLanguage.Items[0].Text = (string)HttpContext.GetLocalResourceObject(
Line 84: "Default.aspx", SelectLanguage, Thread.CurrentThread.CurrentCulture);
Line 85: }
Stack Trace:
[InvalidOperationException: The resource class for this page was not found. Please check if the resource file exists and try again.]
System.Web.Compilation.LocalResXResourceProvider.CreateResourceManager() +4038050
System.Web.Compilation.BaseResXResourceProvider.EnsureResourceManager() +23
System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture) +24
System.Web.Compilation.ResourceExpressionBuilder.GetResourceObject(IResourceProvider resourceProvider, String resourceKey, CultureInfo culture, Type objType, String propName) +32
System.Web.HttpContext.GetLocalResourceObject(String virtualPath, String resourceKey, CultureInfo culture) +56
APPortal.Login.PopulateLanguageList() in c:inetpubwwwrootAPPortalDefault.aspx.cs:83
APPortal.Login.Page_Load(Object sender, EventArgs e) in c:inetpubwwwrootAPPortalDefault.aspx.cs:20
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
View 1 Replies
Feb 24, 2010
Is there any way for me to override the values that are stored in a third party assembly in an embedded resource file?
Using Red Gate's .Net reflector, I can see there are 6 resource items, but I only want to change to of them when using it in my web application.
View 1 Replies
Jul 29, 2010
Is There Any Way or trick to generate local resource for all pages in visual studio 2010 automatically? I have about 500 pages and UserControls. its hard to generate resource for every page one by one.
View 1 Replies
Feb 11, 2010
I have created a webpage called server.aspx and the related local resource file called server.aspx.resx. In the resourcefile I defined the message "{0} is required." with the key Error.
In my .aspx page I access the string:
<asp:RequiredFieldValidator ControlToValidate="textboxName" runat="server" ErrorMessage="<%$ Resources:Error %> ID="validatorName">
Now I want to pass a value, for example the name of the textbox 'Name' to the resource string, so that the errormessage is "Name is required."
Is there any possibility to pass a value to the string?
View 2 Replies
Sep 18, 2010
I am using VS.Net to do a localiztion project, it allows me to create a resource file by going to Tools->Generate Local Resource. However the resouce file generated is not complete in my opinion. Say the following html:
[Code]....
the wizard creates an entry for "Last Name", but not "First Name", is this by design? If yes, how do I work around that?
View 2 Replies
Oct 11, 2010
I need to create both local and global resource file in VB.NET. And also i need to use both resource file in a single page. how to create and use in VB.NET (VS2008).
View 3 Replies
Nov 18, 2010
Why when I generate local resource does it check out the web.config. I've done a comparison after the process has completed and the web.config hasnt changed.I'm using TFS 2010 Basic.It's not a big issue but I would be interested if anyone knows the answer.
View 1 Replies
Oct 25, 2010
While developing I've seen a couple different ways to get local resources values from the resx files. Which one is considered the best practice?
Using the GetGlobalResourceObject method:
<a id="myLink" href="#"><%= GetGlobalResourceObject("Filter","Diary")%></a>
Or using a control and setting the value directly in the resx.
View 1 Replies
Jul 6, 2010
i'm using a little javascript in my website for my navigation bar, which is made up of a few ImageButton controls. in the code behind i have this:
Dim homeImage As String = GetLocalResourceObject("HomeImage")
imgBtnHome.Attributes.Add("OnMouseOver", HomeImage)
and in the resx file, i've tried these, but they don't work: (note the single and double quotes)
key: HomeImage value: "this.src='images/HomeImage.gif'"
key: HomeImage value: "this.src='images/HomeImage.gif'"
is it even possible to read "quoted" text from a local resource file?
View 1 Replies
Oct 11, 2010
Can i use the same "Name"(value is different) in both local and global resource file(.resx) and refer both in same page in VB.NET (VS2008).
View 1 Replies
Jan 12, 2010
How can I use an image or icon resource from global resource file in an asp:Image control to set the ImageUrl attribute?
View 1 Replies
Jun 2, 2010
I will be setting the current thread's culture at the beginning of the request lifecycle.
Does it make sense if I create my own resource.xml to store things like strings/labels/messages that will be used in the web application?
or are their drawbacks and its better if I just use the Global resources .resx files that are 'built-in' ?
View 2 Replies
Apr 7, 2010
In our web application we need to keep various company's settings. For eg "DiamondProdRefIDCaption","Shippingpickup","ZipCodeCaption","DefaultCountry","AllowToEditInvoice", etcThese settings are different for various companies and are placed in web.config as key-value pair.Initially, we have tried do simplify this process by adding a company_settings table in the DB so as to allow us to add companies on the fly. However, this method makes it very difficult to add a new setting
<%$Resources:DiamondProdRefIDCaption%>
View 3 Replies
Sep 22, 2010
I have a large asp.net project to which I want to add MVC functionality. I have added the necessary references into the project (System.Web.Mvc (v 2.0), System.Web.Abstractions (v 3.5) and System.Web.Routing (v 3.5) and amended all the required files (Global.asax (routing requirements), the web.config, project (Controllers and View folders) and created a basic HomeController and ViewPage.
When I run the application and attempt to go to the controller via {serverpath}Home I am getting the error "An unhandled exception has occurred - Could not load file or assembly 'System.Web' or one of its dependencies. The system cannot find the file specified." I've tried browsing the net but the error is too vague; is there a good way to identify exactly why the assembly cannot load?
View 1 Replies
Jan 25, 2010
I have been trying to figure this out and can't... I have seen this code used before but for some reason it will not work in this situation. I have a GridView and I want to truncate cells where the field length is greater than 18 characters and then show the entire contents in a tool tip. The tool tip works fine but I can't get the field contents to truncate. When I run in debugger the tc.text always shows as . but when the page renders there is content in these cells, content over 18 characters. The code never errors out it just never sees the contents as anything but "" and therefore never truncates the field contents.
[Code]....
View 5 Replies
Oct 2, 2010
I get "Endpoint not found" when attempting to access my service via the browser at
[URL]
I get "Error: Cannot obtain Metadata from http://localhost:10093/Services/Service1.svc" when attempting to access the same address from the wcftestclient.
If I place a breakpoint in the service implementation it is hit, so I assume the svc file is setup correctly:
<%@ ServiceHost Language="C#" Debug="true"
Service="MyApp.Core.Service.Service.MyAppService,MyApp.Core.Service"
Factory="CommonServiceFactory.WebServiceHostFactory,CommonServiceFactory" %>
Here is my config:
[code]....
View 3 Replies
Dec 26, 2010
First, I am new to VWD 2010 and attempting to create a data driven website.
I am attempting to return a value from an sql server stored procedure and store that value in a variable. I have searched here and online and tried to follow the examples that I found. However, I have not been successful in making it work.
Here is my stored procedure:
[Code]....
Here is my VB code behind where I am attempting to get the return value:
[Code]....
I know that I have a good connection because I am using the same connection string from my WebConfig file and it is working in other instances.
Below is the error message that is being displayed.
'The formal parameter "@monRegAmt" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output."
View 11 Replies
Feb 2, 2011
I currently have this controller function:
public ViewResult Edit(int id)
{
//get user from id
var user = _adminRepository.GetUser(id);
return View(user);
}
This currently gives me an error on my view page if I attempt to edit an item with an id of 100, when there is no user with an id of 100 in the database. What's the best practice for handling this? Send them to a Create page, or show a friendly error message? Should that redirect functionality be within the controller function?
View 4 Replies
Sep 15, 2010
Attempting to use any of the control toolkit is failing for me. It seems to be failing on the official site, as well. All of the examples are broken, with a javascript error on the page. Here is an example:[URL]
View 8 Replies
Mar 22, 2011
I need to see an errorcode produced by a SqlException - however, I can't get one to fire. I use NHibernate and have a SQL UNIQUE CONSTRAINT setup on my table. When that constraint is violated, I need to catch the error code and produce a user-friendly message based off of that. Here is a sample of my try/catch:
using (var txn = NHibernateSession.Current.BeginTransaction()) {
try {
Session["Report"] = report;
_reportRepository.SaveOrUpdate(report);
txn.Commit();
[Code]....
View 2 Replies
Aug 11, 2010
I have this piece of code for a mailing list signup control.
[Code]....
How can I modify this so I can use a path to a new image for the button.
View 2 Replies
Mar 16, 2010
After I installed the .net framework 3.5 to my iis box (which didn't have any previous version of .net fraemwork), I'm not long able to upload the aspx page via WebDav with MS Expression Web. I got the "HTTP/1.1 403 Forbidden " error message.
Also I got this error "Server Application Unavailable" when trying to open the aspx page. my iis box is not a domain controller nor a backup domain controller.
I have enabled the webservices extention - "ASP.NET v2.0.50727" and "WebDAV";
View 1 Replies
Feb 1, 2011
I am attemting to remote debug my application in a outside server I have the IP and the the user. I am using in my server msvsmom.exe 64bit version 10.3.30319.1. In my computer I have visual studio 2010. I had opened all the port required in the MSDN docimentation in the server and host. I copied my web application in the server.
When I am trying to connect from my VS2010 in "Attach to Process" using in qualifiers this format with the real information : Administrator@xxx.xxx.xxx.xxx
I have this error: "Unable to connect to the Microsoft Visual Studio Remote Debugging Monitor named Administrator@xxx.xxx.xxx.xxx" The visual Studio Remote Debugger does not support this edition of windows"
View 2 Replies
Jan 22, 2010
i m using VSS 2005 and VS 2005. on one machine i installed VSS 2005 and create project. on second machine i opended my project using project source safe, it ask me for user detail and i enter details. i got the complete project. problem is that when i try to run project i got following error. "An editor or project is attempting to check out a file that is modified in memory, which will result in saving it. Saving files during the build process is dangerous and can result in incorrect build outputs in future. Do you want to continue with the check out?"
View 1 Replies