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

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

Export DataTable to Excel/CSV C#

protected void btnExport_Click(object sender, EventArgs e) { DataTable dtTable = new DataTable(); DataRow dtRow; dtTable.Columns.Add(“SNo”, typeof(int)); dtTable.Columns.Add(“Address”, typeof(string)); for (int i = 0; i <= 9; i++) { dtRow = dtTable.NewRow(); dtRow[0] = i; dtRow[1] =…

Read More

calling [Ajax.AjaxMethod()] not working

finally its resolved by using, <system.webServer> <validation validateIntegratedModeConfiguration=”false” /> <modules> <add name=”ScriptModule” preCondition=”integratedMode” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ /> </modules> <handlers> <remove name=”WebServiceHandlerFactory-Integrated” /> <add verb=”POST,GET” name=”Ajax” path=”ajax/*.ashx” type=”Ajax.PageHandlerFactory, Ajax” /> <add name=”ScriptHandlerFactory” verb=”*” path=”*.asmx” preCondition=”integratedMode”…

Read More

404 error WCF on server

Add below lines undser System.Server / handler section. <add name=”svc-ISAPI-2.0″ path=”*.svc” verb=”*” modules=”IsapiModule” scriptProcessor=”%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll” resourceType=”Unspecified” preCondition=”classicMode,runtimeVersionv2.0,bitness32″ /> <add name=”svc-Integrated” path=”*.svc” verb=”*” type=”System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″ resourceType=”Unspecified” preCondition=”integratedMode” />

Read More