How to set uiculture for AjaxControl - asp.net

I have an asp.net application that is entirely in the Dutch language (Culture and UICulture) This is set in the header of the aspx:
<%# Page Language="vb" AutoEventWireup="false" UICulture="nl" Culture="nl-NL" CodeBehind="CSSSR_BlokjesSchema.aspx.vb" EnableEventValidation="false" Inherits="CS_SSR_RAIO.CSSSR_BlokjesSchema" %>
This workes perfectly, but not for the Ajax calendar extender. In that component, the dates and month names are still displayed in English.
What am i forgetting?? What setting in Ajax makes my calendar use the Culture i set?

I found it myself
The toolkit scriptmanager needs to be explicitly told that is has to use localisation:
<ajaxControlToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server" CombineScripts="true"></ajaxControlToolkit:ToolkitScriptManager>
After i changed this, the calendar was showing the date descriptions in Dutch

Related

ASP.NET - Hyperlink relative path to current URL on ASPX page not in code behind

I tried this one but the href code is not generated
<asp:HyperLink ID="hlPrev" NavigateUrl="<%# this.Request.Url %>" runat="server" />
Is there any way to do this on aspx page not in the code behind?
If hlPrev is located outside of DataBound controls like GridView, there are two problems in our code -
You want to use <%= %> instead of <%# %> which is used in DataBound controls.
You cannot use <%= %> to set property of a server control. Basically, you cannot mix runat="server" with <%= %>.
Solution:
Click Me

Ajax Calendar Extender doesn't work

I know this is a silly question, bu I just can't get the ASP.Net Calendar Extender work. I am looking at this problem for hours now.
Can someone please help me.
I've downloaded the code from the Asp.net Ajax website and I've added the dll to my toolbox.
This is the code of my page
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CalendarExtender TargetControlID="TextBox1" runat="server"></asp:CalendarExtender>
When I click the TextBox, it behaves like a normal TextBox. It doesn't show the calendar.
Is there something I forget, or is there something I am doing wrong?
Replace ScriptManager With ToolkitScriptManager
You forgot to set the PopupButtonID property of the CalendarExtender. If you want the calendar to appear when you click on the TextBox, use PopupButtonID="TextBox1"

Why is my user control not instanciated on a postback?

I'd like to set the trigger of an UpdatePanel to a user control outside the UpdatePanel on the same page . The user control is added at design time, not at runtime.
If I statically declare the trigger, I get an error "A control with ID 'xx' cannot be found for the trigger in UpdatePanel". I tried to add the trigger at runtime in Page_Init or Page_Load, but it fails with the user control being null, although it has ViewState enabled. Has someone an idea on how to solve this?
Here is the code of the user control:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="ComponentDropDownControl.ascx.cs" Inherits="ComponentDropDownControl" EnableViewState="true" %>
<asp:DropDownList ID="ComponentDropDown" runat="server" DataSourceID="ComponentFile"
DataTextField="name" DataValueField="name" OnSelectedIndexChanged="ComponentDropDown_SelectedIndexChanged" AutoPostBack="True" EnableTheming="True">
</asp:DropDownList><asp:XmlDataSource ID="ComponentFile" runat="server" DataFile="~/App_Data/Components.xml" XPath="//component"></asp:XmlDataSource>
And here it is in the aspx page:
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="create.aspx.cs" Inherits="create" Title="Create task" %>
<%# Register Src="ComponentDropDownControl.ascx" TagName="ComponentDropDownControl"
TagPrefix="uc1" %>
...
<uc1:ComponentDropDownControl ID="CustomComponentDropDown" runat="server" EnableViewState="true" />
In the Page_Load function of the aspx page, the following lines work at first time, but fail on the first PostBack (line 2, CustomComponentDropDown is null).
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = CustomComponentDropDown.UniqueID.ToString();
UpdatePanel1.Triggers.Add(trigger);
EDIT: user control is not instanciated because it is cached. In fact, it seems impossible to have a user control being both cached and able to handle events. I must be missing something because that seems pretty shitty behavior to me.
If anyone knows what I'm'doing wrong, please tell.
In what scenario would you want to handle events and have the control cached? The only reason I see to handle events is either to change internal state, or change the display state. In either case, caching will remove that possibility.
Did you register the Control as a async postback control?
ScriptManager1.RegisterAsyncPostBackControl(CustomComponentDropDown);
Also, shouldn't
trigger.ControlID = CustomComponentDropDown.UniqueID.ToString();
Simply be
trigger.ControlID = CustomComponentDropDown.ID;

Ajax change language

I saw in a lot of AjaxControlToolkit.resources.dll for different languages, even mine (Russian) in my bin folder so I guess that's real to change the language of my Ajax Calendar Extender.
<asp:TextBox ID="TextBox4" runat="server" oninit="TextBox4_Init" />
<ajaxToolkit:CalendarExtender ID="TextBox4_CalendarExtender" runat="server"
Enabled="True" FirstDayOfWeek="Monday" Format="dd.MM.yyyy"
TargetControlID="TextBox4" />
<br />
It's English by default
But how can I change it to my Language ? (or to the current culture language)
I've tried
<%# Page Title="gfregrhtrhr" Language="Nemerle" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
CodeBehind="Report.aspx.n" Inherits="Flow_WEB_Nemerle.Report" Culture="ru-RU" UICulture="ru-RU" %>
but it made no sense for calendar :-/
by the way I have some fun in comparing my page and
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Calendar/Calendar.aspx
there I can see month names etc on Russian BUT "Today" an english >_< instead on my page month names are English and "Today" is Russian "Сегодня" ... is it phenomenon
Finally fixed by adding
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnableScriptGlobalization="true" EnableScriptLocalization="true"/>
The components are going to work by default in the language defined in the page culture property in your page directive. This directive also fix the date format and all the culture relative parameters and preferences.
This is an example to set them work for English-United Kingdom:
<%# Page Language="C#" Culture="en-UK" UICulture="en-UK" %>
You must set EnableScriptGlobalization="true" in ToolkitScriptManager like this
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="True"></asp:ToolkitScriptManager>

ASP.NET Controls are not coming in Code-behind IntelliSense

I am having an aspx page where I have added one asp.net text box control with ID and RUNAT attribute. But in Code-behind I am not seeing this control's name in the intellisense.
My page directive in aspx is as follows
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyProject_UI._Default" %>
I am using VS 2008. Any idea how to get rid of this?
Try using CodeFile instead of CodeBehind. The latter is a hold-over from .NET 1.1.
Also, make sure the namespaces match up between the markup and the code. Do a test compile to be sure.
I have seen this on occasion when I edit a page. When it happens to me, I close the files and open them again and it seems to fix itself.
This will happen if you are trying to include your control in LayoutTemplate. For example if you are using an asp label in a login control you have converted to a LayoutTemplate.
<asp:Login ID="userLogin" runat="server">
<LayoutTemplate>
<!--Username and password controls-->
<asp:Button ID="btnLogin" CommandName="Login" runat="server" Text="Login" />
<asp:Label ID="lblAlert" runat="server"></asp:Label>
</LayoutTemplate>
So your lblAlert will not show up on the code behind take it out of the layouttemplate or use a loop to find the control within the layout object.
var mylabel = (Label)userLogin.FindControl("lblAlert");

Resources