Skip to main content

Posts

Showing posts from January, 2012

Dynamic Table Generate and Fill Data

Dynamic Table Generate and Fill Data sample.aspx  <div id = "roomsdiv" runat="server">        </div> sample.aspx.cs fds = cls.selectFloor();         DataRowCollection fcdr = fds.Tables[0].Rows;         table = "<table align='center' style='width: 70%' border='0'>";                    foreach (DataRow fdr in fds.Tables[0].Rows)             {                 table += "<tr>";                 table += "<tr>";                 rds = cls.selectRoom(fdr["floorid"].ToString());                 if (rds.Tables[0].Rows.Count > 0)                 {                     table += "<td height='20' width ='40' class='roomfloor'>" + fdr["floorname"] + "</td>";                     table += "<td height='20' width ='10'> </td>";                     foreach (DataRow rd

Encrypt & Decrypt the Data

Encrypt & Decrypt Data using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Text; using System.Security.Cryptography; using System.IO; using System.Diagnostics; /// <summary> /// Summary description for EncryptDecrypt /// </summary> public class EncryptDecrypt {     public EncryptDecrypt()     {         //         // TODO: Add constructor logic here         //     }     public static String Encrypt(string source)     {         DESCryptoServiceProvider des = new DESCryptoServiceProvider();         byte[] Key = { 12, 13, 14, 15, 16, 17, 18, 19 };         byte[] IV = { 12, 13, 14, 15, 16, 17, 18, 19 };         ICryptoTransform encryptor = des.CreateEncryptor(Key, IV);         try         {             byte[] IDToBytes = ASCIIEncoding.A

Tool tip by javascript

 Tool tip by javascript: Copy the code under the </head> tag <style type="text/css"> #dhtmltooltip{ position: absolute; width: 150px; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; /*Remove below line to remove shadow. Below line should always appear last within this CSS*/ filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135); } </style> Copy the code under the </body> Tab <div id="dhtmltooltip"></div> <script type="text/javascript"> var offsetxpoint=-60 //Customize x offset of tooltip var offsetypoint=20 //Customize y offset of tooltip var ie=document.all var ns6=document.getElementById && !document.all var enabletip=false if (ie||ns6) var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "" function ietruebody(){ retu

copy data between form fields by javascript

copy data between form fields by javascript  JavaScript: <script type="text/javascript"> function CopyAddress() { if(document.getElementById("ctl00_cphhead_chkpresentaddress").checked) { document.getElementById("ctl00_cphhead_txtpermantaddress").value=document.getElementById("ctl00_cphhead_txtaddress").value; } else { document.getElementById("ctl00_cphhead_txtpermantaddress").value=""; } } </script> Present Address TextBox:     <asp:TextBox ID="txtaddress" runat="server" TextMode="MultiLine" Height="50px"                     Width="140px" onkeyup="CopyAddress();"></asp:TextBox></td> CheckBox: <asp:CheckBox ID="chkpresentaddress" runat="server" onclick="CopyAddress();" />

CSS Message Boxes for different message types

CSS Message Boxes for different message types 1. Information messages The purpose of information messages is to inform the user about something relevant. This should be presented in blue because people associate this color with information, regardless of content. This could be any information relevant to a user action. 2. Success messages Success messages should be displayed after user successfully performs an operation. By that I mean a complete operation - no partial operations and no errors. For example, the message can say: "Your profile has been saved successfully and confirmation mail has been sent to the email address you provided". This means that each operation in this process (saving profile and sending email) has been successfully performed. 3. Warning messages Warning messages should be displayed to a user when an operation couldn't be completed in a whole. For example "Your profile has been saved successfully, but confirmation mai

Page Error method

How to use the Page_Error method The Page_Error event handler provides a way to trap errors that occur at the page level. You can simply display error information (as the sample code to follow does), or you can log the event or perform some other action. Note This example displays detailed error information in the browser only for demonstration purposes. You will want to be cautious when displaying detailed information to the end user of the application, especially when the application is running on the Internet. A more appropriate action would be to display a message to the user notifying them that an error has occurred, and then actually logging the specific error details in the event log. This example throws a null exception, which forces an error to occur in the Page_Load event handler. Follow these steps to create the initial page that will demonstrate using the Page_Error event handler. Follow these steps to add a new file named

Reset Identity column in SQL Server

How To: Reset Identity column in SQL Server This is one of those simple tip posts that may seem obvious and taken for granted by those of us who have been working with SQL Server for a while now but maybe a newbie or two out there will find this helpful. Every so often (just this morning!) I find myself resetting an identity column value back to 0 after I've deleted all the existing records so the table gets a fresh start at primary key 1. Yes, I know all about primary keys not changing and how the value in the primary key doesn't matter and so on. Sometimes I just like the primary keys starting at 1. The following line resets the Identity value for the Customer table to 0 so that the next record added starts at 1. DBCC CHECKIDENT('Customer', RESEED, 0)