Saturday, December 17, 2011

How to validate a number between 0-24 with Java Scripts

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script language="javascript" type="text/javascript">
        function checkIt(obj, evt) {
            evt = (evt) ? evt : window.event
            var charCode = (evt.which) ? evt.which : evt.keyCode
            if ((charCode < 45 || charCode > 57) && charCode != 8 && charCode != 37 && charCode != 39) {
                alert("This field accepts numbers only")
                return false
            }
            var t = (charCode / 1) - 48;
            var v = obj.value + t;
            var value = v / 1;
            if(value > 24){ 
                alert("Number should be less than 24");
                return false;
            }
            return true
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox runat="server" ID="txtNumber" onKeyPress='javascript:return checkIt(this, event)' />
    </div>
    </form>
</body>
</html>

Wednesday, December 14, 2011

How to retain the password in a postback

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test Page</title>
    <script runat="server">
        public string Password
        {
            get { return ViewState["Password"as string; }
            set { this.ViewState["Password"] = value; }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (this.IsPostBack)
            {
                if (!string.IsNullOrEmpty(this.txtPassword.Text))
                    this.Password = this.txtPassword.Text;
                this.txtPassword.Attributes.Add("value"this.Password ?? string.Empty);
            }
        }
    </script>
</head>
<body>
    <form  id="aspNetForm" runat="server">
        UserName: <asp:TextBox runat="server" ID="txtName" />
        Password: <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" />
        <hr />
        <asp:Button runat="server" ID="btnSave" Text="Save" />
    </form>
</body>
</html>

Tuesday, December 13, 2011

Html Header Tag Sizes

  • H1 - 24pt / 32px
  • H2 - 18pt / 24px
  • H3 - 14pt / 18px
  • H4 - 12pt / 15px
  • H5 - 10pt / 13px
  • H6 - 8pt   / 11px
Above are the default font sizes in points and their approximate sizes in pixels

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...