Skip to main content

Posts

Populate Date DropDown using Javascript

Set the values of Dropdown list of a date:- There are three dropdown lists for each Day, Month And Year.  we fill through javascript with following way:         var date =" 11/23/2010 "; // Format- MM/DD/YYYY         var mm = date.substring(0,2);         var dd = date.substring(3,5);         var yy = date.substring(6,10);                 document.getElementById(" ddlDay ").value=dd;         document.getElementById(" ddlMonth ").value=mm;         document.getElementById(" ddlYear ").value=yy;

Default Button, asp.net

Default Button for a page:                   <form id="form1" runat="server" defaultbutton="buttonName"> < /form > Default Button for a panel:                    < asp:Panel runat = "server" DefaultButton = "lbHello" > < /asp:Panel > Default in a div:-                    < div onkeypress="javascript:return WebForm_FireDefaultButton(event, 'buttonID')" > < /div > For Linkbutton to make a default page, add below javascript at the end of the page <script type="text/javascript">     var __defaultFired = false; function WebForm_FireDefaultButton(event, target) {     var element = event.target || event.srcElement;     if (!__defaultFired && event.keyCode == 13 ...

How to Remove duplicate records - Sql-server 2005

Query to remove duplicate records, in this query please add all the columns in GROUP BY clause that are duplicate, it is based on primary key DELETE from TableName WHERE CoumnName1 + CoumnName2 + CoumnName3 IN (select CoumnName1 + CoumnName2 + CoumnName3         FROM TableName         group by CoumnName1 , CoumnName2 ,CoumnName3         having Count(ID)>1) AND ID NOT IN (select MAX(ID) from TableName         WHERE CoumnName1 + CoumnName2 + CoumnName3         IN (select CoumnName1 + CoumnName2 + CoumnName3                 FROM TableName                 group by CoumnName1 , CoumnName2 ,CoumnName3                 having Count(ID)>1)  ...

How to DownLoad a File in ASP.NET ?

To DownLoad a file:- 1. Add a link to page, Like this :-                <a href="Download.ashx?FileName=file.pdf&FilePath=DownLoad/">Download Standing Order Mandate</a >           Where file.pdf = file to download                      DownLoad = Folder name where the file placed at server. 2. Then  Add a Generic Handler to the website/project with the name Download.ashx and add the following code:    public void ProcessRequest(HttpContext context)     {         if (context.Request.QueryString["FileName"] != null && context.Request.QueryString["FilePath"] != null)         {           ...

Date Format, C#

Date Fromat Output dd-MMM-yyyy 15-Feb-2010 dd-MM-yyyy 15-02-2010 dd-MMM-yyyy hh:mm:ss 15-Feb-2010 11:25:56 dd-MMM-yyyy hh:mm tt 15-Feb-2010 11:25 AM dd-MMM-yy 15-Feb-10 MMM dd, yyyy Feb 15, 2010 MMMM dd, yyyy April 15, 2010 Example: DateTime objDt = DateTime.Now; objDt.ToString("dd-MMM-YYYY") = 15-Feb-2010