Skip to main content

Posts

Showing posts from February, 2011

Common Regular Expressions

Common Regular Expressions Some common regular expressions are shown in Table 1. Table  Common Regular Expressions Field Expression Format Samples Description Name ^[a-zA-Z''-'\s]{1,40}$ John Doe O'Dell Validates a name. Allows up to 40 uppercase and lowercase characters and a few special characters that are common to some names. You can modify this list. Social Security Number ^\d{3}-\d{2}-\d{4}$ 111-11-1111 Validates the format, type, and length of the supplied input field. The input must consist of 3 numeric characters followed by a dash, then 2 numeric characters followed by a dash, and then 4 numeric characters. Phone Number ^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[- .]?\d{3}[- .]?\d{4}$ (425) 555-0123 425-555-0123 425 555 0123 1-425-555-0123 Validates a U.S. phone number. It must consist of 3 numeric characters, optionally enclosed in parentheses, followed by a set of 3 numeric characters and then a set of 4 numeric characters. E-mail ^(?("")(...

Count characters left on keypress using javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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 runat="server">     <title>Untitled Page</title>     <script type="text/javascript" language="javascript">      function CountTxtLeft(StrTxt, txtCount, totaltxt) {     if (StrTxt.value.length > totaltxt)      {         StrTxt.value = StrTxt.value.substring(0, totaltxt);         }     else     {         txtCount.value ='Total characters left :' + (totaltxt - StrTxt.value.length);         } }     </script> </head> <body...

Ten more CSS tricks you may not know

1. Block vs. inline level elements Nearly all  HTML  elements are either block or inline elements. The  characteristics of block elements  include: Always begin on a new line Height, line-height and top and bottom margins can be manipulated Width defaults to 100% of their containing element, unless a width is specified Examples of block elements include  <div> ,  <p> ,  <h1> ,  <form> ,  <ul>  and  <li> . Inline elements  on the other hand have the  opposite characteristics : Begin on the same line Height, line-height and top and bottom margins can't be changed Width is as long as the text/image and can't be manipulated Examples of inline elements include  <span> ,  <a> ,  <label> ,  <input> ,  <img> ,  <strong>  and  <em> . To change an element's status you can use  display: inline  or...

Show loading image during button click..

Using ASP.NET AJAX UpdateProgress Control Hi, You can use the Ajax Updatepanel with Ajax update Progress to solve this problem. Step1: Put your button in an update panel Step2: Drop an UpdateProgress to your webform and associate this with your updatepanel <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> </asp:UpdateProgress> Step3: Create a template for your "Loading" text to be shown when you click the button and put that inside the updateprogress's <ProgressTemplate> tag <ProgressTemplate> <div>loading</div> </ProgressTemplate> you can add the some style like position absolute, etc to t...

Calling Server Side Code from Client Side using Ajax

How to call Server Side function from Client Side Code using PageMethods in ASP.NET AJAX You cannot call server-side code ‘directly’ from client-side code. That is because by design, the server side code executes at server side and client side code at the client. However there are some workarounds. To call serverside code from javascript, you will need to use AJAX, and the easiest way out, is to use the ASP.NET AJAX Extensions. One option while using Microsoft ASP.NET AJAX is to call ASP.NET Web services (.asmx files) from the browser by using client script. The script can call a webservice containing server-based methods (Web methods) and invoke these methods without a postback and without refreshing the whole page. However this approach could be overkill sometimes, to perform the simplest of tasks. Moreover the logic needs to be kept in a separate .asmx file. We need something that is more ‘integrated’ with our solution. The option we are going to use in this article involves PageMe...