ComponentOne Input for ASP.NET AJAX: Input for ASP.NET AJAX Quick Start > Step 4 of 5: Add a Culture Setting

Step 4 of 5: Add a Culture Setting

This topic demonstrates how to add code to Button_Click events to set the Culture for the C1DateInput and C1CurrencyInput controls. To do this, complete the following steps:

1.   Click the Design tab located below the Document window to switch to Design view.

2.   From the Toolbox, select the Button control and place it on your Web form (below the table) by performing a drag-and-drop operation. Repeat this step to add a second Button control to your Web form.

3.   You should now have two Button controls placed next to each other on your form. Change some basic settings in the Properties window:

 

Button1 Properties:

Button2 Properties:

(ID) = FrenchBtn

(ID) = USEnglishBtn

Text = French Culture

Text = U.S. English Culture

Height = 25px

Height = 25px

Width = 130px

Width = 130px

 

4.   Double-click the French Culture button to create an event handler for the button's Click event. Enter the following code for the FrenchBtn_Click event:

      Visual Basic

Protected Sub FrenchBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FrenchBtn.Click

    Me.C1DateInput1.Culture = New System.Globalization.CultureInfo("fr-FR")

    Me.C1CurrencyInput1.Culture = New System.Globalization.CultureInfo("fr-FR")

End Sub

      C#

protected void FrenchBtn_Click(object sender, System.EventArgs e)

{

 this.C1DateInput1.Culture = new System.Globalization.CultureInfo("fr-FR");

 this.C1CurrencyInput1.Culture = new System.Globalization.CultureInfo("fr-FR");

}

5.   Double-click the U.S. English Culture button to create an event handler for the button's Click event. Enter the following code for the USEnglishBtn_Click event:

      Visual Basic

Protected Sub USEnglishBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles USEnglishBtn.Click

    Me.C1DateInput1.Culture = New System.Globalization.CultureInfo("en-US")

    Me.C1CurrencyInput1.Culture = New System.Globalization.CultureInfo("en-US")

End Sub

      C#

protected void USEnglishBtn_Click(object sender, System.EventArgs e)

{

 this.C1DateInput1.Culture = new System.Globalization.CultureInfo("en-US");

 this.C1CurrencyInput1.Culture = new System.Globalization.CultureInfo("en-US");

}

You have successfully added two button controls with culture information to your Web form. The following image shows the appearance of the updated Web form:

 

 

The next topic shows how to run the application. It also lists tasks for you to complete to observe the functionality of the Web form.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.