Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, May 13, 2010

How to set text to a Password TextBox in ASP.NET

txtPassword.Attributes["value"] = "Password123";

Get the difference of month between two dates


private
static int monthDifference(DateTime startDate, DateTime endDate)

{       int monthsApart =
12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
      return Math.Abs(monthsApart);



}

To solve apostrophe problem in where condition of SQL Statement


If ur query contain single apostrophe like this

SELECT * FROM Products WHERE ProductName = 'King's Jalepenos'

Then replace ur single apostrophe with two apostrophe like

SELECT * FROM Products WHERE ProductName ='King''s Jalepenos'



Better do it in C# coding as follows


string

str = "King''s Jalepenos";

str= str.Replace("'","''");

WinCV.exe - viewing the contents of any DOT NET namespace

WinCV.exe is a tool for viewing the contents of any DOT NET namespace. It is resides in C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin

Memory Management for ASP.NET & making space for C: drive

By Default ASP.Net store all the page requested at C:\Documents and Settings\SURENDRAS\ASPNET\Local Settings\Temp. So delete all the files within this folder for improving performance & for making space in C drive.

Create HTML Table in ASP.NET


Table one Table & say Run as a server control. Its Id is 
tblIntangiblesInner





public

void FillIntangibleTable()


            {


                 ArrayList arrList = null;


                 arrList = (ArrayList)LoadAllIntangibles();


                 foreach (object
item in arrList)


                 {


                       HtmlTableRow theRow = new HtmlTableRow();


                       HtmlTableCell []theCell = new
HtmlTableCell[2];


                       theCell[0] = new HtmlTableCell();


                       theCell[1] = new HtmlTableCell();


                       theCell[0].Width = "5%";


                       theCell[1].Width = "95%";


                       theCell[0].InnerHtml = " ";


                       theCell[1].InnerHtml = "<a
href=default.aspx?GSIN="
+item.ToString()+">"
+ item.ToString() + "</a>";


                       theRow.Cells.Add(theCell[0]);


                       theRow.Cells.Add(theCell[1]);


                       tblIntangiblesInner.Rows.Add(theRow);


                 }



           }






public

ArrayList LoadAllIntangibles()


            {


                 System.Collections.ArrayList obj = new
System.Collections.ArrayList();


                 obj.Add("2");


                 obj.Add("3");


                 obj.Add("4");


                 obj.Add("5");


                 obj.Add("6");


                 obj.Add("7");


                 return obj;



           }




Printting a file in .NET

Dim psiPrint As New System.Diagnostics.ProcessStartInfo()
psiPrint.Verb = "print"
psiPrint.WindowStyle = ProcessWindowStyle.Hidden
psiPrint.FileName = "C:\MyFile.pdf"
psiPrint.UseShellExecute = True
System.Diagnostics.Process.Start(psiPrint)