Skip to main content

Posts

Showing posts from October, 2011

Validate asp.net form using Jquery

  Validate asp.net form using Jquery   In this post I will show you how to validate asp.net form using jqery. Create a new website,add a new js file ,and add following code inside it function validateForm(e) { var formIsValid = true; // check that a valid email address has been entered var emailRegExp = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/; if (!emailRegExp.test(String($("#txtEmail").val()).toUpperCase())) { addError("txtEmail", "Please enter a valid email address."); formIsValid = false; } else { removeError("txtEmail"); } // check that first name has one or more characters if ($("#txtFirstName").val() == '') { addError("txtFirstName", "This field is required."); formIsValid = false; } else { removeError("txtFirstName"); } // check that last name has one or more characters if ($("#txtLas

Compress and decompress data in c#

In this post,I will show you how to compress and decompress data in   c# using GzipStream class.Below is the code for the same using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.IO.Compression; namespace CompressDecompress {     class Program     {         const string CompressFilePath = @"C:\temp\data.zip";         const string Filename = @"C:\temp\data.txt";         private const string DeCompressFilePath = @"C:\temp\data1.txt";         static void Main(string[] args)         {             Compress(Filename);             Decompress(CompressFilePath);         }         private static void Decompress(string compressFilePath)         {             using (FileStream inputStream = new FileStream(compressFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))             {                 using (FileStream outputStream = new FileStream(DeCompressFilePath

Enable/disable dropdownlist through a checkbox selection

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default2.aspx.vb" Inherits="Default2" %> <!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 id="Head1" runat="server">     <title></title>     <script src="http://code.jquery.com/jquery-1.6.4.js" type="text/javascript"></script>     <script type="text/javascript">         $(document).ready(function () {             $("#chkEnable").click(function () {                 if (this.checked)                     $('#ddlList').attr('disabled', 'disabled');                                   else                     $('#ddlList').removeAttr('disabled');             });         });     <

Open div popup with a LightBox effect

Open div popup with a LightBox effect   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DivBox.aspx.cs" Inherits="DivBox" %> <!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"> function showBox() {   var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;   var layer = document.createElement('div');   layer.style.zIndex = 2;   layer.id = 'layer';   layer.style.position = 'absolute';   layer.style.top = '0px';   layer.style.left = '0px';   layer.style.height = document.documentElement.scrollHeight + 'px';  

Create Dynamic Div Using Javascript

Create Dynamic Div Using Javascript   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicDiv.aspx.cs" Inherits="DynamicDiv" %> <!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>Javascript create new div</title>     <style type="text/css">    .dynamicDiv {    width : 200px;    height : 100px;    border : solid 1px #c0c0c0;    background - color : #e1e1e1;    font - size : 11px;    font - family : verdana;    color : #000;    padding : 5px;    }    </style>     <script type="text/javascript" language="javascript"> function createDiv() {    var divTag = document.createElement("div")