2009-09-22 109 views
1

您好我发现分析器错误问题

我创建了一个Global.asax文件,并编写代码

private void Application_BeginRequest(Object source, EventArgs e) 
{ 
    string[] languages = HttpContext.Current.Request.UserLanguages; 

    if (languages[0].ToLower() != null && languages[0].ToLower()!="") 
    { 

     System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(languages[0].ToLower()); 

     System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(languages[0].ToLower()); 

    } 
} 

,并定义标签筛选

多语种Asp.Net Web应用程序的问题
<asp:Label ID="Labeldg" runat="server" Text="<%$ Resources:Resource, Labeldg %>"</asp:Label> 

但是,通过分析程序错误,如:

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The resource object with key 'LblUsrName_Login' was not found. Source Error:

</div>

<div class="impcLoginText_Login">

<asp:Label ID="LblUsrName" runat="server" Text="<%$ Resources:PageResource, LblUsrName_Login %>" "></asp:Label>

+0

我看到这个错误吗?你是说你尝试在你的global.asax中添加一个标签吗? – David 2009-09-22 13:19:51

回答

0

除非我读到这个错误,它看起来像我试图在global.asax中放置一个标签。 global.asax没有可见的用户界面,因此您不能在其中添加标签。

0

该标签指定该字符串驻留在PageResource中,该应该是App_GlobalResources文件夹中的resx文件。如果它不存在,那么它没有找到,你会得到你在这里看到的错误。

可以添加resx文件并放入正确的条目或更改标记以从现有的resx文件读取。

+0

我假设你没有把标签放在global.asax文件中,因为这太疯狂了;) – SecretDeveloper 2009-09-22 13:51:42