Input for ASP.NET WebForms
Step 4 of 5: Add a Culture Setting
Quick Start > 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 C1InputDate and C1InputCurrency 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 = 140px
  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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Protected Sub FrenchBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FrenchBtn.Click
        C1InputDate1.Culture = New System.Globalization.CultureInfo("fr-FR")
        C1InputCurrency1.Culture = New System.Globalization.CultureInfo("fr-FR")
    End Sub
    

    To write code in C#

    C#
    Copy Code
    protected void FrenchBtn_Click(object sender, System.EventArgs e) 
    { 
      C1InputDate1.Culture = new System.Globalization.CultureInfo("fr-FR");
                C1InputCurrency1.Culture = new System.Globalization.CultureInfo("fr-FR");
     
    }
    
  5. 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.

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Protected Sub USEnglishBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles USEnglishBtn.Click
        C1InputDate1.Culture = New System.Globalization.CultureInfo("en-US")
        C1InputCurrency1.Culture = New System.Globalization.CultureInfo("en-US")
    End Sub
    

    To write code in C#

    C#
    Copy Code
    protected void USEnglishBtn_Click(object sender, System.EventArgs e) 
    { 
    C1InputDate1.Culture = new System.Globalization.CultureInfo("en-US");
                C1InputCurrency1.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.