show-notice
hide-notice

Thursday, 4 July 2013

MaskedEditExtender DisplayMoney in asp.net ajax




Introduction: 



MaskedEdit is an ASP.NET AJAX extender that attaches to a TextBox control to restrict the kind of text that can be entered. MaskedEdit applies a "mask" to the input that permits only certain types of characters/text to be entered. The supported data formats are: Number, Date, Time, and DateTime. MaskedEdit uses the culture settings specified in the CultureName property. If none is specified the culture setting will be the same as the page: English (United States).

Description:

MaskedEditValidator is a custom validator which attaches to the MaskedEdit extender and its associated TextBox and verifies that the input text matches the pattern specified in the MaskedEdit extender. Once associated with a validation group, server- and client-side validation can be performed and used to display messages.







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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server"> 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            Label1.Text = "You submitted salary: " + TextBox1.Text; 
        } 
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Ajax MaskedEditExtender DisplayMoney - How to use in MaskedEditExtender</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color: DodgerBlue; font-style: italic;">
            Ajax MaskedEditValidator Example: Using DisplayMoney</h2>
        <hr width="550" align="left" color="SkyBlue" />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
        <br />
        <asp:Label ID="Label1" runat="server" Font-Size="X-Large" ForeColor="Green" Font-Bold="true"> 
        </asp:Label>
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Your Salary [9999 Format]" ForeColor="Orange"
            Font-Bold="true"> 
        </asp:Label>
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="HotPink" Font-Size="Large"
            Font-Names="Comic Sans MS"> 
        </asp:TextBox>
        <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1"
            DisplayMoney="Left" Mask="9999" MaskType="Number" MessageValidatorTip="true">
        </cc1:MaskedEditExtender>
        <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1"
            ControlExtender="MaskedEditExtender1" IsValidEmpty="false" InvalidValueMessage="inputted salary is not valid"
            EmptyValueMessage="Input salary"> 
        </cc1:MaskedEditValidator>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit Your Salary"
            Height="40" Font-Bold="true" ForeColor="DodgerBlue" />
    </div>
    </form>
</body>
</html>








SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com