How to use watermark property on password textbox in a web-page?

Here I am giving you an example where you can see that watermark property works fine with required field validator in Asp.Net. This whole process can be done by using simple jQuery tricks. In my concept we have 2 textboxes and one of them is <asp:TextBox ID=”txtPassword” runat=”server” Style=”height: 18px;… Continue reading

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

What's the difference between Page.RegisterClientScriptBlock and Page.RegisterStartupScript?

RegisterClientScriptBlock is for returning blocks of client-side script containing functions. RegisterStartupScript is for returning blocks of client-script not packaged in functions-in other words, code that’s to execute when the page is loaded. The latter positions script blocks near the end of the document so elements on the page that the script interacts are… 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