I am trying to implement Globalization in my application but for some reason its not working
Please find the code below
Default.aspx
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Button ID="button1" meta:resourceKey="button1" runat="server" Text="" />
</asp:Content>
Default.aspx.cs
protected override void InitializeCulture()
{
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("en");
Thread.CurrentThread.CurrentUICulture = new
CultureInfo("en-US");
base.InitializeCulture();
}
name of my resource file is Default.aspx.en-us.resx in "App_LocalResources" folder
it carries only one key
key-->button1.Text
value--> Save
Please advice
I followed your instructions and got the same results as you, except for the error. The problem I found was that unless there is a default resource file then the language specific one does not work for some reason.
So I made a copy of the default.aspx.en-us.resx, and named it default.aspx.resx in the same directory, and then made sure that the default.aspx.en-us.resx had a different value than the default and it worked.
Related
Keep Getting this error when running Site:
Error parsing attribute 'page': Cannot create an object of type 'System.Web.UI.Page' from its string representation '' for the 'Page' property.
.aspx file:
<%# Page Title="Home Page" Page Language="VB" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class ="Home1">
</div>
</asp:Content>
vb file:
Partial Class _Default
Inherits System.Web.UI.Page
End Class
take out the word page, and just keep Language (you already used it at the start)
Language="VB"
Ok, so i am doing a project with ASP.net, and using Visual Studio 2012. I created a new master page, in which i wish to make registration. I simply drop the "Create User Wizard" in the Login toolbox onto my page, and it goes completely off its hinges!!
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Register.aspx.vb" Inherits="WebApplication1.Register1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" Height="10px" Width="10px">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>
I cannot get anything inline like my previous pages.
Any suggestions?
It's not because wizard or something, it's about styles. You have a better browser (Chrome), just open your page in Chrome, right-click on desired element and choose "Inspect element".
Then take a magnifier:
Point this tool to desired element and check out styles on the right:
Try to enable/disable them right there, and you'll see result immediately.
I have a aspx page name MakeRedemption.aspx, the code is something as following :
<%# Page Title="Make Redemption" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="MakeRedemption.aspx.cs" Inherits="MakeRedemption" %>
<%# Register Src="~/UserControls/MakeRedemption_SearchGift.ascx" TagName="MakeRedemption_SearchGift" TagPrefix="uc" %>
<asp:Content ID="Content2" ContentPlaceHolderID="bodyContent" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"></asp:UpdatePanel>
<uc:MakeRedemption_SearchGift runat="server" ID="ucSearchGifts" GiftCategoryAvailable="false" /><% /*UnitCostAvailable="true"*/ %>
</asp:Content>
And I have a user control page name MakeRedemption_SearchGift.ascx.
I would like to ask, is the MakeRedemption.aspx consider a parent page for MakeRedemption_SearchGift.ascx ??
And MakeRedemption_SearchGift.ascx is the user control page of MakeRedemption.aspx
Kindly advise.
Yes, it is. After do some research, testing, further with senior advice. It is.
In my Summary page, I have two CalendarExtender controls to enable someone to select Start Date and End Date for database queries.
In the head of my Summary.aspx page, I have the following declarations:
<%# MasterType VirtualPath="~/Site.Master" %>
<%# Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
<% #Import Namespace="System.Globalization" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
For the page itself, I have a ToolkitScriptManager, two (2) TextBox controls, two CalendarExtender controls, and a GridView control:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" />
<asp:TextBox ID="txtStartDate" runat="server" />
<asp:CalendarExtender ID="calExStartDate" runat="server" TargetControlID="txtStartDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" />
<asp:TextBox ID="txtEndDate" runat="server" />
<asp:CalendarExtender ID="calExEndDate" runat="server" TargetControlID="txtEndDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" DaysModeTitleFormat="MM/dd/yyyy" DefaultView="Months" Enabled="True" TodaysDateFormat="MMMM dd, yyyy" />
<asp:GridView ID="summaryGridView" runat="server" />
In the Page_Load event in the C# code, I have placed the following:
protected void Page_Load(object sender, EventArgs e) {
MasterPage = (SiteMaster)Page.Master;
if (!Page.IsPostBack) {
calExEndDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
calExStartDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
}
}
So, why are my Calendar controls not working? There are no values in the calendars and the language appears to be Spanish.
Just add EnableScriptGlobalization="true" in your ScriptManager like this:
Your language is Spanish and I believe it's so because your UICulture is UICulture="es" (ESpañol) and Culture="es-MX" (Español México).
See this line on your markup:
<%# Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
The rest of your markup looks okay to me.
I have had this problem for a while now and no matter what i cannot seem to resolve it. I have a master page and a content page.
The content page simply contains a button
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</asp:Content>
The master page simply contains the content place holders. The button1 one event fires normally, however as soon as a form is added to the master page the button stops firing. the master page looks something like this
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
Member Login
<asp:Button ID="btnLogin" runat="server" Text="Login" CssClass="bt_login"
onclick="btnLogin_Click" />
</form>
</div>
</div>
</div>
</div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</form>
Can some one please help, the button works fine without the form in teh master page, however i need a form in the master page
Thanks
Ok after running the exact same project on another machine, everything worked fine. So I'm guessing there is an issue with the way i installed visual studio and asp.net.