only My site

Saturday, December 13, 2008

Retrive all columns in the DB


To Retrive Full columns in a DB
======================

select distinct
TBL.name as TableName,
COL.Name as ColumnName, TYP.name as Type, COL.max_length as Length,
COL.precision as Precision, CASE COL.is_nullable WHEN 1 THEN 'Null' ELSE 'Not Null' end as 'Null' from sys.columns COL
inner join sys.objects TBL on COL.object_id= TBL.object_id
inner join sys.types TYP on TYP.system_type_id= COL.system_type_id
where TBL.type ='u' and TBL.name != 'sysdiagrams'
and TYP.name !='sysname' order by
TBL.name,
COL.name

DataTable Load()


DataTable's Load method.
===================

string sql = "Select * from MyTable";
SqlCommand cmd = new SqlCommand(sql, MyConnection);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();

//Load the SqlDataReader object to the DataTable object as follows.
dt.Load(dr);

Response.Write(dt.Rows.Count.ToString());

Merge DataSet


DataSet.Merge(ds)
==============

For the merge to take place between the datasets, apart from the data type and column name, the table name should also be the same.
Dim myConnection as New SqlConnection (strConn)

Dim DS1 As DataSet
Dim DS1 As DataSet
Dim MyCommand As SqlDataAdapter

MyCommand = new SqlDataAdapter("exec s_get_table1", MyConnection)
DS1 = new DataSet()
MyCommand.Fill(DS1, "MyTable")

MyCommand = new SqlDataAdapter("exec s_get_table2", MyConnection)
DS2 = new DataSet()
MyCommand.Fill(DS2, "MyTable")

'Now the code works because the table name for both datasets are the same.
'Also the data type and column name for both tables are the same.

ds1.merge(ds2)

MyDataGrid.DataSource=DS1.tables(0).DefaultView
MyDataGrid.DataBind()

Globalization - Display currency


using System;
using System.Globalization;

public class TestClass
{
public static void Main()
{
int i = 100;

// Creates a CultureInfo for English in Belize.
CultureInfo bz = new CultureInfo("en-BZ");
// Displays i formatted as currency for the bz.
Console.WriteLine(i.ToString("c", bz));

// Creates a CultureInfo for English in the U.S.
CultureInfo us = new CultureInfo("en-US");
// Display i formatted as currency for us.
Console.WriteLine(i.ToString("c", us));

// Creates a CultureInfo for Danish in Denmark.
CultureInfo dk = new CultureInfo("da-DK");
// Displays i formatted as currency for dk.
Console.WriteLine(i.ToString("c", dk));
}
}

Saturday, August 30, 2008

Wednesday, July 30, 2008

c# String functions Part1

// Create a Unicode String with 5 Greek Alpha characters
String szGreekAlpha = new String('\u0319',5);
// Create a Unicode String with a Greek Omega character
String szGreekOmega = new String(new char [] {'\u03A9','\u03A9','\u03A9'},2,1);

String szGreekLetters = String.Concat(szGreekOmega, szGreekAlpha, szGreekOmega.Clone());

// Examine the result
Console.WriteLine(szGreekLetters);

// The first index of Alpha
int ialpha = szGreekLetters.IndexOf('\u0319');
// The last index of Omega
int iomega = szGreekLetters.LastIndexOf('\u03A9');

Console.WriteLine("The Greek letter Alpha first appears at index " + ialpha +
" and Omega last appears at index " + iomega + " in this String.");

Window - open, move

Window.open method opnes a window and window.move method Moves the screen position of the upper-left corner of the window to the specified iX and iY position.


mywindow=window.open('BalaSanHome.aspx','whatever','toolbar=no,status=no,width=500,height=250,scrollbars=no,directories=no,location=no,resizable=no,menubar=no,screenX=400,screenY=300,top=290,left=600' ,true);
mywindow.moveTo(300,300);

Correlated Sub query - Sample

SELECT Id, Status_Date,Status_Description FROM T1612_INV_STATUS [ST]
WHERE Status_Date = ( SELECT Max(Status_Date) FROM T1612_INV_STATUS WHERE [ST].Id = Track_Id)

Master Page - Tips

When using masterPage system, i can't access the "ScriptManager1" object within the codebehind of ContentPage file..
You access the scriptManager from a content page using the static GetCurrent method:

ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);

Also we can use Type casting..

if (((MasterPage)Master).FindControl("ScriptManager1") != null)
{
ScriptManager scm;
scm = (ScriptManager)((MasterPage)Master).FindControl("ScriptManager1");
scm.SetFocus(txtHdrDet_CMNumber);
}

Tuesday, July 29, 2008

Los Angeles earthquake

I felt the shake and we came out from the office.

The USGS says a magnitude-5.4 earthquake has struck the L.A, area. Stay with CNN.com Live for continuing coverage.


A moderate, magnitude 5.4 earthquake struck just east of Los Angeles, the U.S. Geological Survey says. The epicenter was about 2 miles southwest of Chino Hills. No injuries or serious damge were reported. But residents were warned to check homes for gas leaks and to be on alert for more aftershocks. "Everything was moving," said iReporter Danny Casler.

Monday, July 28, 2008

Build Events

The screen shot illustrates the post build event( copy dll assembly to d:\ass..path)...You can play around with the events in VS 2005,2008.

TabIndex Property

Browser URL is the first one will get the focus by Default. It can be changed by settong the Focus to a control in the ASP.Net webform. Eg txtInvNo.focus(); Also set the TabIndex property to move the cursor in a customized order.

focus() function won't work in MS AJAX update panel....

Narayana Murthy's words of wisdom

Way back in 1981, Nagavara Ramarao Narayana Murthy and six other young engineering graduates launched an information technology company from a garage in Mumbai.

Murthy had borrowed Rs 10,000 from his wife (Sudha) to launch Infosys Technologies. Infy, as it is popularly known, recently, reported a net profit of Rs 1,302 crore (Rs 13.02 billion) for the quarter ended June 2008.

For 21 years Murthy served as the company's chief executive officer, before he handed over the reins to co-founder Nandan M Nilekani in March 2002.

His life's philosophy and his Success Mantra, read on...

"We were huddled together in a small room in Bombay (now Mumbai) in the hope of creating a brighter future for ourselves, for the Indian society, and perhaps, we dreamed, even for the world."

"Our value system was like the British Constitution - it was all unwritten but extremely well practiced...Our value system is the true strength of Infosys."

"Unless we can sell well we cannot do anything, such as create jobs, pay good salaries and satisfy investors. Right from the beginning we realised that we have to focus on selling better and better in the marketplace."

"Truth is God. Our success at Infosys depends on our continual learning."

"Entrepreneurship is about running a marathon, not a 100 metre dash."

Thursday, July 24, 2008

Wednesday, July 23, 2008

InsertAfter


using System;
using System.IO;
using System.Xml;

public class Sample {

public static void Main() {

XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +

"<title>Pride And Prejudice</title>" +

"</book>");

XmlNode root = doc.DocumentElement;

//Create a new node.
XmlElement elem = doc.CreateElement("price");
elem.InnerText="19.95";

//Add the node to the document.
root.InsertAfter(elem, root.FirstChild);

Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);

}
}

XMLAttributionCollection, Item


public class Sample
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' publicationdate='1997'> " +

" <title>Pride And Prejudice</title>" +

"</book>");

XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

Console.WriteLine("Display all the attributes for this book...");
for (int i=0; i < attrColl.Count; i++)
{
Console.WriteLine("{0} = {1}", attrColl.Item(i).Name, attrColl.Item(i).Value);
}

}
}

HTTP, BaseURL(Uniform Resource Indicator)


using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main()
{
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.Load("http://localhost/baseuri.xml");

//Display information on the attribute node. The value
//returned for BaseURI is 'http://localhost/baseuri.xml'.
XmlAttribute attr = doc.DocumentElement.Attributes[0];
Console.WriteLine("Name of the attribute: {0}", attr.Name);
Console.WriteLine("Base URI of the attribute: {0}", attr.BaseURI);
Console.WriteLine("The value of the attribute: {0}", attr.InnerText);

}
}

Attributes collection


using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main(){

XmlDocument doc = new XmlDocument();
doc.LoadXml("" +
"" +
"
");

//Create an attribute collection.
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

Console.WriteLine("Display information on each of the attributes... \r\n");
foreach (XmlAttribute attr in attrColl){
Console.Write("{0}:{1} = {2}", attr.Prefix, attr.LocalName, attr.Value);
Console.WriteLine("\t namespaceURI=" + attr.NamespaceURI);
}
}
}

XmlTextWriter & MemoryStream


private byte[] GenerateXXXXXML()
{
byte[] distBytes = new byte[1];

using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
XmlTextWriter xtw = new XmlTextWriter(ms, Encoding.UTF8);
xtw.Formatting = Formatting.Indented;
xtw.WriteProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
xtw.WriteStartElement("PRODValidation");
xtw.WriteAttributeString("xmlns", "http://www.XXX.com/PRODUCT/validate");

// charge type
xtw.WriteStartElement("Query");
xtw.WriteAttributeString("name", "TABLENAME");
xtw.WriteStartElement("Parameters");
xtw.WriteStartElement("Param");
xtw.WriteAttributeString("name", "");
xtw.WriteAttributeString("value", "");
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.WriteStartElement("Result");
xtw.WriteStartElement("Status");
xtw.WriteEndElement();
xtw.WriteStartElement("AdditionalInfo");
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.WriteEndElement();

xtw.WriteEndElement();
xtw.Flush();
ms.Flush();
distBytes = ms.ToArray();
xtw.Close();
}

return distBytes;
}

DataRow Null check

DataRow Null checking before cast to the corresponding datatype.

alertRules.Condition = dr.IsNull("Condition") ? "" : dr["Condition"].ToString();

Copy File from remote location (HTTP, https, FTP..)


string RemoteFolder = @"http://yoursite.com/YourWebFolder/";
string RemoteFile = "yourfile.txt";
string url = RemoteFolder + RemoteFile;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new
StreamReader(webResponse.GetResponseStream(),Encod ing.ASCII);
string filecontent = sr.ReadToEnd();
StreamWriter sw = new StreamWriter("c:\mynewfile.txt");
sw.Write(filecontent);
sw.Flush();
sw.Close();
sr.Close();

Tuesday, July 22, 2008

XML DOM - Samples

<?xml version='1.0'?>

<bookstore xmlns="urn:newbooks-schema">

<book genre="novel" style="hardcover">

<title>The Handmaid's Tale</title>

<author>

<first-name>Margaret</first-name>

<last-name>Atwood</last-name>

</author>

<price>19.95</price>

</book>

<book genre="novel" style="other">

<title>The Poisonwood Bible</title>

<author>

<first-name>Barbara</first-name>

<last-name>Kingsolver</last-name>

</author>

<price>11.99</price>

</book>

</bookstore>





using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main()
{

XmlDocument doc = new XmlDocument();
doc.Load("newbooks.xml");

// Create an XmlNamespaceManager to resolve the default namespace.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("bk", "urn:newbooks-schema");

// Select and display all book titles.
XmlNodeList nodeList;
XmlElement root = doc.DocumentElement;
nodeList = root.SelectNodes("/bk:bookstore/bk:book/bk:title", nsmgr);
foreach (XmlNode title in nodeList) {
Console.WriteLine(title.InnerXml);
}

}

}


CreateElement:
==============

using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main()
{
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +

"<title>Pride And Prejudice</title>" +

"</book>");

//Create a new node and add it to the document.
//The text node is the content of the price element.
XmlElement elem = doc.CreateElement("price");
XmlText text = doc.CreateTextNode("19.95");
doc.DocumentElement.AppendChild(elem);
doc.DocumentElement.LastChild.AppendChild(text);

Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);

}
}


using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main()
{
//Create the XmlDocument.
XmlDocument doc = new XmlDocument();

//Create a document type node and
//add it to the document.
XmlDocumentType doctype;
doctype = doc.CreateDocumentType("book", null, null, "");
doc.AppendChild(doctype);

//Create the root element and
//add it to the document.
doc.AppendChild(doc.CreateElement("book"));

Console.WriteLine("Display the modified XML...");
doc.Save(Console.Out);
}
}

StringDictionary - Collection

StringDictionary is the member of System.Collections.Specialized class

Example:


using System;
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringDictionary {

public static void Main() {

// Creates and initializes a new StringDictionary.
StringDictionary myCol = new StringDictionary();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );

// Display the contents of the collection using foreach. This is the preferred method.
Console.WriteLine( "Displays the elements using foreach:" );
PrintKeysAndValues1( myCol );

// Display the contents of the collection using the enumerator.
Console.WriteLine( "Displays the elements using the IEnumerator:" );
PrintKeysAndValues2( myCol );

// Display the contents of the collection using the Keys, Values, Count, and Item properties.
Console.WriteLine( "Displays the elements using the Keys, Values, Count, and Item properties:" );
PrintKeysAndValues3( myCol );

// Copies the StringDictionary to an array with DictionaryEntry elements.
DictionaryEntry[] myArr = new DictionaryEntry[myCol.Count];
myCol.CopyTo( myArr, 0 );

// Displays the values in the array.
Console.WriteLine( "Displays the elements in the array:" );
Console.WriteLine( " KEY VALUE" );
for ( int i = 0; i < myArr.Length; i++ )
Console.WriteLine( " {0,-10} {1}", myArr[i].Key, myArr[i].Value );
Console.WriteLine();
// Searches for a value.
if ( myCol.ContainsValue( "amarillo" ) )
Console.WriteLine( "The collection contains the value \"amarillo\"." );
else
Console.WriteLine( "The collection does not contain the value \"amarillo\"." ); Console.WriteLine();

// Searches for a key and deletes it.
if ( myCol.ContainsKey( "green" ) )
myCol.Remove( "green" );
Console.WriteLine( "The collection contains the following elements after removing \"green\":" ); PrintKeysAndValues1( myCol );

// Clears the entire collection.
myCol.Clear();
Console.WriteLine( "The collection contains the following elements after it is cleared:" ); PrintKeysAndValues1( myCol );
}

// Uses the foreach statement which hides the complexity of the enumerator.
// NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.


public static void PrintKeysAndValues1( StringDictionary myCol )
{
Console.WriteLine( " KEY VALUE" );
foreach ( DictionaryEntry de in myCol )
Console.WriteLine( " {0,-25} {1}", de.Key, de.Value ); Console.WriteLine(); }

// Uses the enumerator.
// NOTE: The foreach statement is the preferred way of enumerating the contents of a collection.

public static void PrintKeysAndValues2( StringDictionary myCol )
{
IEnumerator myEnumerator = myCol.GetEnumerator();
DictionaryEntry de;
Console.WriteLine( " KEY VALUE" );
while ( myEnumerator.MoveNext() )
{
de = (DictionaryEntry) myEnumerator.Current;
Console.WriteLine( " {0,-25} {1}", de.Key, de.Value );
}
Console.WriteLine();
}
// Uses the Keys, Values, Count, and Item properties.
public static void PrintKeysAndValues3( StringDictionary myCol )
{
String[] myKeys = new String[myCol.Count];
myCol.Keys.CopyTo( myKeys, 0 );
Console.WriteLine( " INDEX KEY VALUE" );
for ( int i = 0; i < myCol.Count; i++ )
Console.WriteLine( " {0,-5} {1,-25} {2}", i, myKeys[i], myCol[myKeys[i]] );
Console.WriteLine();
}
}

Contains() XPath Function in MS DOM

<?xml version="1.0"?>

<!-- This file represents a fragment of a bookstore inventory database -->

<bookstore specialty="novel">

<book>

<Title>Beginning XML</Title>

<Publisher>Wrox</Publisher>

</book>

<book>

<Title>Professional XML</Title>

<Publisher>Wrox</Publisher>

</book>

<book>

<Title>Programming ADO</Title>

<author>

<first-name>Mary</first-name>

<last-name>Bob</last-name>

</author>

<datePublished>1/1/2000</datePublished>

<Publisher>Microsoft Press</Publisher>

</book>

</bookstore>



Add References, by selecting the Microsoft XML 3.0 check box.

Dim doc As MSXML2.DOMDocument
Dim nlist As MSXML2.IXMLDOMNodeList
Dim node As MSXML2.IXMLDOMNode

Set doc = New MSXML2.DOMDocument
doc.setProperty "SelectionLanguage", "XPath"
doc.Load "c:\books.xml"
Set nlist = doc.selectNodes("//book/Title[contains(.,'ADO')]")
MsgBox "Matching Nodes : " & nlist.length

For Each node In nlist
Debug.Print node.nodeName & " : " & node.Text
Next

Source : http://support.microsoft.com/kb/304265

Friday, July 18, 2008

House Model in America

InfranView - Effects



Effects of InfranView s/w - Rock and Zoom Blur..Its cool and fun..

Thursday, July 17, 2008

Entcomm office




Shirdi Sai Baba temple - Los Angeles


InfranView - Image tool


InfranView is a great freeware program that you can download at http://www.irfanview.com and have a really fun time playing with and distorting your own images, as well as using it for normal, everyday editing.

UFrame = Iframe + UpdatPanel

UFrame combines the goodness of UpdatePanel and IFRAME in a cross browser and cross platform solution. It allows a DIV to behave like an IFRAME loading content from any page either static or dynamic. It can load pages having both inline and external Javascript and CSS, just like an IFRAME. But unlike IFRAME, it loads the content within the main document and you can put any number of UFrame on your page without slowing down the browser. It supports ASP.NET postback nicely and you can have DataGrid or any other complex ASP.NET control within a UFrame. UFrame works perfectly with ASP.NET MVC making it an replacement for UpdatePanel. Best of all, UFrame is implemented 100% in Javascript making it a cross platform solution. As a result, you can use UFrame on ASP.NET, PHP, JSP or any other platform.
UFrame does not use IFRAME nor UpdatePanel and thus it is very fast.

<div class="UFrame" id="UFrame1" src="SomePage.aspx?ID=UFrame1" >
<p>This should get replaced with content from Somepage.aspx</p>
</div>

Response from SomePage.aspx is rendered directly inside the UFrame. Here you see two UFrame's are used to load the same SomePage.aspx as if they are loaded inside IFRAME. Another UFrame is used to load AnotherPage.aspx that shows photos from Flickr.

ASP.Net - DoPostBack

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DoPostback.aspx.cs" Inherits="DoPostback" %>

<!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 language="javascript" type="text/javascript">

function enablePostBack()

{

alert("Hi");

//TextBox1 is the first argument(name of control) second argument is "TextChanged" (Serverside event name)

__doPostBack("TextBox1","TextChanged");

}

</script>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

</div>

</form>

</body>

</html>


Server side Code

using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class DoPostback : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.GetPostBackEventReference(TextBox1);

if ( !IsPostBack )
{
TextBox1.Attributes.Add("onblur", "Javascript:enablePostBack();");
}
}

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
TextBox2.Text = (Int16.Parse(TextBox1.Text) * 45).ToString();
}
}

Wednesday, July 16, 2008

Display HTML without Execute

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Example</title>

<script language="JavaScript" type="text/javascript">

<!--

function showTags()

{

str=document.getElementById("txtCode").value;

str=str.replace(/[&]/g,'&amp;');

str=str.replace(/[<]/g,'&lt;');

str=str.replace(/[>]/g,'&gt;');

str=str.replace(/[\n]/g,'<br>');



//document.getElementById('show').innerHTML=str;

document.getElementById('txtCodeop').value = str;

}

//-->

</script>

</head>

<body onload="showTags()">

<div id="show"></div>

<TextArea id="txtCode" name="txtCode"></textArea>

<input type=button id=btnSubmit name=btnSubmit onclick="Javascript:showTags();">

<TextArea id="txtCodeop" name="txtCodeop"></textArea>

</body>

</html>

Monday, July 7, 2008

Sort Dropdown List

Hi...

There is no option in Dropdown server control to Sort the list items as like Array sort method. So a small workaround need to do this. Here is a simple sample.

ddlModelType.DataValueField = "key";
ddlModelType.DataTextField = "value";
ddlModelType.DataSource = strDict;
ddlModelType.DataBind();
SortDropDown(ddlModelType);
ddlModelType.Items.Insert(0, new ListItem("Select", "-1"));

private void SortDropDown(DropDownList dd)
{
ListItem[] ar = new ListItem[dd.Items.Count];
long i = 0;
foreach (ListItem li in dd.Items)
{
// ERROR: Not supported in C#: ReDimStatement
ar[i] = li;
i += 1;
}
ListItem[] ar1 = ar;
Array.Sort(ar1, new ListItemComparer());
dd.Items.Clear();
dd.Items.AddRange(ar1);
//dd.Items.AddRange(ListItem ar1);
}

class ListItemComparer : IComparer
{
int System.Collections.IComparer.Compare(object x, object y)
{
ListItem a = (ListItem)x;
ListItem b = (ListItem)y;
CaseInsensitiveComparer c = new CaseInsensitiveComparer();
return c.Compare(a.Text, b.Text);
}
}

VS 2008 Shortcuts & Code snippets

Build
======

Ctrl + Shift + B - Build Solution
Ctrl + Attach to Process

Debugging
===========
F9 - Break point / Toggle Breakpoint
Ctrl + Shift + F9 - Clear All Breakpoints
Ctrl + B + T - Book mark
Ctrl + B + E - Enable Bookmark
Ctrl + B + C - Clear all Bookmarks
Ctrl + B + P - Previous Bookmark
Ctrl + B + N - Next Bookmark

F2 / Crtl + R + R - Rename function with preview

Edit
=====
Cycle Clip Board ring
Ctrl + Shift + V

Ctrl + F - Quick find (Current Document)
Ctrl + Shift + F - Find in files (Entire solution)
Ctrl + Shift + H - Find & Replace
Alt + F12 - Find Symbol
F8 and SHIFT + F8 - Forward and backwards in your search results

Ctrl+E,D - Format Document
Ctrl+E,F - Format Selection or Current cursor line
Ctrl+Shift+U - Make Uppercase
Ctrl+U - Make Lowercase

Comment Selection (Ctrl+E,C)
28. Uncomment Selection (Ctrl+E,U)
Delete Horizontal White Space (Ctrl+E, \)
24. View White Space (Ctrl+E,S)
25. Word Wrap (Ctrl+E,W)
26. Incremental Search (Ctrl+I)


Crtl + Up Arror - Scroll line Down
Crtl + Down Arror - Scroll line Up

Code Snippets
=============

Ctrl + K, Ctrl + X

Create XML file and sinppet to add snippet using Ctrl + k , ctrl _ x.

Add your code in CDATA Tag and save the XML files as "FileName.snippet" Format.

Use Snippet Manager (Ctrl + k, Ctrl + B) to Import the snippet.

Create own Code snippets inside VS
http://msdn.microsoft.com/en-us/library/bb245788.aspx

Saturday, June 21, 2008

C# Code Snippets


Page Control Iteration
=======================



How many TextBoxes would you like to create? (Please choose vaule between 1 and 10)


MinimumValue="1" MaximumValue="10" Type="Integer"
ErrorMessage="Make sure that you choose a value between 1 and 10!" />


OnClick="CreateTextBoxes" />






***************************************************
Splitting the string into array using delimiter - ToCharArray()
===================================================
string = "\r\n";
char[] splitter = string.ToCharArray();
***************************************************
DBnULL IN DATA ROW
===================
dr.IsNull("Doctype1") ? Convert.ToInt32(dr["Doctype1"]) : 0;

***************************************************
REF:
====
LoadData( ref dsNotify );

protected void LoadData(ref DataSet dsAuthors)
{


}
***********************************************************

***********************************************************

***********************************************************

***********************************************************

Javascript : Using Math functions

function Multiply()
{//No of Hrs / No. of retry = Retry frequency
//Eg: 39 / 10 = 3.9 which is equal to 4 Hrs and 30 Mins
var var1,var2,var3;
var intHrs;
var intMins;
var1 = parseFloat(document.getElementById("txtop1").value );
var2 = parseFloat(document.getElementById("txtop2").value);
if ( isNaN(var1) isNaN(var2) )
{
var3 = 0;
document.getElementById("txtop3").value = "0:00" ;

return true;
}
var3 = var2 / var1;
intHrs = Math.floor(var3);
if (var3 - intHrs > 0.59)
{
intMins = (var3 - intHrs) - 0.60;
intHrs += 1;
}
else
{
intMins = var3 - intHrs;
}
intMins = intMins.toFixed(2) * 100;
document.getElementById("txtop3").value = intHrs + ":" + intMins ;
return true;
}



Add Dataset table using Reader

// connection and query details
String connect = "your-connection-string";
const String SQL = "SELECT TOP 5 OrderID, OrderDate, ShipName, ShipCity, "
+ "ShipCountry FROM [Orders];"
+ "SELECT TOP 5 * FROM [Order Details];"
+ "SELECT TOP 5 CustomerID, CompanyName, Address, City, "
+ "Country FROM [Customers]";

// create a connection, command and get a DataReader
using (SqlConnection con = new SqlConnection(connect))
{
SqlCommand cmd = new SqlCommand(SQL, con);
con.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

// create an array of table names for first two incoming rowsets
String[] tablenames = new String[] {"Orders", "Order Details"};

// load the data from the DataReader
// no existing data, but have to provide a value for LoadOptions
// so use OverwriteRow - makes no difference in this case
DataSet ds = new DataSet();
ds.Load(reader, LoadOption.OverwriteRow, tablenames);

// load another table directly using the Load method
DataTable dt = new DataTable();
dt.TableName = "Customers";
dt.Load(reader);
ds.Tables.Add(dt);

// display the results
...
}

Visual Studio 2008 - Tips & Issues

Visual studio : 1
When paste a code in aspx file, the designer will not get updated until there is no error in the aspx .Eg: the pasted code have the same Id as of the current page then it will not update this control id and rest of the ids in the pasted code.
Visual studio : 2
"Clean Solution" - The Solution Explorer in Visual Studio 2005 now makes it easy for you to clean up unwanted files. Simply choose Clean Solution from the Build Menu and all the intermediate files and output directories in your whole solution will be removed. This is a quicker and easier way to perform the same cleanup as you could in the command line environment with the following syntax:
devenv /clean SolnConfigName SolutionName
http://msdn.microsoft.com/en-us/vs2005/aa718635.aspx

DVD Player s/w

I tried AVS DVD player and its cool. Its totally free..

Sunday, June 15, 2008

Wallpapers - Six flags

Hi..
I got few chances to click the Natural sceneries.. Hope you like it.