C#

Monday, February 3, 2014

Localize control in Asp.net Using C#.net

Introduction

Use the Localize control to reserve a location on a Web page in which to display localized text.Controls that are outside the body element are ignored.
The Localize control inherits from the Literal control and is identical to it in every way. The Localize control is used at design time to distinguish static text that can be localized from other static text. Although the Label control allows you to apply a style to the displayed text, the Localize control does not.
You can programmatically manage the text displayed in the control by setting the Literal.Text property, inherited from the Literal control.
This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application.
 ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input.

Example:


The following code example demonstrates how to use the Localize control to display static text.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Localize Example</title>
<script runat="server">

      void ButtonClick(Object sender, EventArgs e)
      {
         Localize1.Text="Welcome to ASP.NET!! This is localized text.";
      }

   </script>

</head>
<body>
   <form id="Form1" runat="server">
      <h3>Localize Example</h3>

      <asp:Localize id="Localize1"
           Text="Hello World!!"
           runat="server"/>

      <br /><br />

      <asp:Button id="Button1"
           Text="Change Localize Text"
           OnClick="ButtonClick"
           runat="server"/>

   </form>
</body>
</html>


No comments:

Post a Comment