How to use CustomValidator in aspx page?

The CustomValidator control allows you to write a method to handle the validation of the value entered in aspx page and you can use this in this way: <asp:CustomValidator ID=”CustomValidator1″ runat=”server” ErrorMessage=”Sms length is exceeding over 160.” ClientValidationFunction=”validateLength” ControlToValidate=”txtSmsMessage” SetFocusOnError=”True” ValidationGroup=”add”>*</asp:CustomValidator> <script language=”javascript” type=”text/javascript”> function validateLength(oSrc, args) { args.IsValid =… Continue reading

Open a new Tab/Window by using Response.Redirect and it open in new web page

Here I am going to explain how to open new tab/window on Button click using asp.net. A week ago, i have to implement that code. I have option to use java-script windows.open to open new tab. But I have to insert or update some database entry. Yeah i know that… Continue reading

How to JSON Serialization and Deserialization in ASP.NET

JSON is one kind of data format which is designer for running JavaScript on website. At present, JSON is widely used in web. This article focuses on JSON Serialization and Deserialization in ASP.NET, including the brief introduction of JSON, how to serialize and deserialize with ASP.NET and operation on date,… Continue reading

Calling Postback from Javascript

There may be some scenario where you may want to explicitly postback to the server using some clientside javascript. It is pretty simple to do this. ASP.NET already creates a client side javascript method as shown below to support Postbacks for the web controls: function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit… Continue reading

How to add watermark on a textbox by using javascript?

There are 3 ways to add watermark functionality on a textbox by using javascript. <asp:TextBox ID=”TextBox1″ Text=”Search” runat=”server” onfocus=”javascript:if(this.value==’Search’){this.value=’’;}” onblur=”javascript:if(this.value==’’) {this.value=’Search’;}” /> Or <script language=”javascript” type=”text/javascript”> function WaterMark(txtValue, txtWaterMark) { if (txtValue.value == txtWaterMark) txtValue.value = ”; else txtValue.value = txtWaterMark; } </script> <asp:TextBox ID=”TextBox1″ Text=”Search” runat=”server” onblur=”WaterMark(this,’Search’);” onfocus=”WaterMark(this,’Search’);” />… Continue reading

How to disable back button of browser?

By using java script it can be done <script language=”JavaScript”>javascript:window.history.forward(1);</script> Or <A HREF=”PageName.htm” onclick=”javascript:location.replace(this.href); event.returnValue=false; “>No back button when you do this.</A> Or <html><head><title>Back Button Demo: Page One</title> <script> function backButtonOverride() {  setTimeout(“backButtonOverrideBody()”, 1);  } function backButtonOverrideBody() { try { history.forward(); } catch (e) { } setTimeout(“backButtonOverrideBody()”, 500); } </script></head><body… Continue reading

Calling Server Code by using javascript

Implementing Client Callbacks Programmatic Without Post-backs in ASP.NET Web Pages How can we call c# server side code by using java-script. Here i am given you an example in which i described that how to call it Use this code in aspx page <html xmlns=”http://www.w3.org/1999/xhtml”> <head runat=”server”> <title></title> </head> <script type=”text/javascript”> function ReceiveServerData(arg, context)… Continue reading