Most important topics

Static Constructor A static constructor is used to initialize the static data once or performed an action to once only. A static constructor does not take access modifiers or have parameters. A static constructor is called…

Read More

UK Postcode Validation

Regular expression for JavaScript var regPostcode = /^([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zA-Z][0-9][0-9]|[a-zA-Z][0-9]){1}([ ])([0-9][a-zA-z][a-zA-z]){1}$/; var result = regPostcode.test(SearchTerm); if (!result) { alert(“Please enter valid postcode”); return false; } Regular expression for C# string regPostcode = “([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zA-Z][0-9][0-9]|[a-zA-Z][0-9]){1}([ ])([0-9][a-zA-z][a-zA-z]){1}”; System.Text.RegularExpressions.Regex regx = new…

Read More

SQL Server Transaction

BEGIN TRANSACTION BEGIN TRY — put SQL commands here INSERT/UPDATE/Delete — if successful – COMMIT the work COMMIT TRANSACTION END TRY BEGIN CATCH — handle the error case (here by displaying the error) SELECT ERROR_NUMBER() AS…

Read More

How to display Progress bar while page is loading

<pre> <code> protected void Page_Load(object sender, EventArgs e) { showPageLoad(); //do somthing     } private void showPageLoad() { int i=0; Response.Write(“<div id=’divTitle’>Loading(<span id=’message’>0%</span>)</div>”); Response.Flush(); for(i=5;i<=100;i=i+5) { System.Threading.Thread.Sleep(200);// any codes can be typed here outputflash(i.ToString() + “%”);…

Read More

Download / Upload Files on FTP Server

Require following ftp details where you want to upload the files: FTP URL: “ftp://ftp.yoursite.com/” FTP Username: username FTP Password: password FTP Port: 21 Upload File public string UploadFile(string FtpUrl, string fileName, string userName, string password, string…

Read More