Tuesday, December 30, 2008

How To Turn On Visual Studio 2005 Line Numbering

Step 1:

Select Tools from the menu.


Step 2:

Select Options in Tools Menu,When The Options Dialog is open Select and Expand Text Editor From Tree View.





Step 3:

Select C# Node, you can see Display on the Righthand side, below that there is An Line Number Checkbox which unchecked by Default.



Step 4:

Select that Line Number Checkbox once it checked Click Ok Button.




Step 5:

After that when you see your codebehind part there will line number displaying on your window.


How To Create Menu Dynamically With Child Elements

protected void Page_Load(object sender,  EventArgs e)
{

Menu
myMenu = new Menu();
this.form1.Controls.Add(myMenu);
MenuItem mnItem = new MenuItem("Dyamnic Menu");
myMenu.Items.Add(mnItem);


MenuItem menuNodeChild = new MenuItem("Xploredotnet");
mnItem.ChildItems.Add(menuNodeChild);
menuNodeChild.NavigateUrl =
"http://www.Xploredotnet.com";
menuNodeChild = new
MenuItem("ASP.NET");
mnItem.ChildItems.Add(menuNodeChild);
menuNodeChild.NavigateUrl =
"http://www.asp.net";


myMenu.Orientation =
Orientation.Horizontal;
//myMenu .Orientation = Orientation.Vertical;
}

How To Add Menu Dynamically

protected void Page_Load(object sender,  EventArgs e)
{

Menu
myMenu = new Menu();
this.form1.Controls.Add(myMenu);
MenuItem mnItem = new MenuItem("test");
myMenu.Items.Add(mnItem);
myMenu.Orientation =
Orientation.Horizontal;
//myMenu .Orientation = Orientation.Vertical;
}

How To Get The List Of Database Available In Particular Server

SELECT * FROM master.dbo.sysdatabases

Thursday, December 25, 2008

How To Delete A Duplicate Records From Table

Query To Find The Duplicate Records

SELECT ColumnName1,ColumnName2,ColumnNameN,count(*) As UserDefinedColName
FROM TableName
GROUP BY ColumnName1,ColumnName2,ColumnNameN
HAVING count(*) > 0

Query To Delete Duplicate Records

select distinct * into #tmpTableName from TableName
truncate table TableName
insert TableName select * from #tmpTableName
drop table #tmpTableName

Saturday, December 20, 2008

What's the difference between ISNULL & COALESCE

ISNULL()

It replace the NULL with the specified replacement value. The value of check_expression is returned if it is not NULL; otherwise, replacement_value is returned after it is implicitly converted to the type of check_expression, if the type is different.

Syntax

ISNULL ( check_expression , replacement_value )

check_expression

The expression to be checked for NULL. check_expression can be of any type.

replacement_value

Is the expression to be returned if check_expression is NULL. replacement_value must be of a type that is implicitly convertible to the type of check_expresssion.

COALESCE()

Returns the first nonnull expression among its arguments.

Syntax

COALESCE ( expression [ ,...n ] )

expression

It'can be of any type.

Note:
ISNULL()
and COALESCE() though both are equivalent, but they behave differently. An expression involving ISNULL with non-null parameters is considered to be NOT NULL, while expressions involving COALESCE with non-null parameters is considered to be NULL.

For More Inforamtion :

ISNULL() or COALESCE()?

Performance: ISNULL vs. COALESCE

ISNULL() <> COALESCE(). Discuss

What Is th difference between Is Null & COALESCE

ISNULL (Transact-SQL)

COALESCE (Transact-SQL)

Friday, December 19, 2008

whats the difference between sp_helptext and sp_help

sp_helptext
sp_helptext displays the definition of a user-defined rule, default, unencrypted Transact-SQL stored procedure, user-defined Transact-SQL function, trigger, computed column, CHECK constraint, view.

Syntax:-
sp_helptext [ @objname = ] 'name' [ , [ @columnname = ] computed_column_name ]

Example:
Exec sp_helptext proc_name.

sp_help
sp_help reports information about a database object (any object listed in the sysobjects
table), a user-defined data type

Syntax:-
sp_help [ [ @objname = ] name ]

Example:
EXEC sp_help tablename

Thursday, December 18, 2008

How to check whether temp table exist

if object_id('tempdb..##temptblname') is not null
drop table ##temptblname

Failed to access IIS metabase

Cause:-
When you install IIS AFTER .NET 2.0 framework, the rights of the ASPNET user had not been set correctly.

In Command Prompt Go to this following Location

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 then type aspnet_regiss -i


Wednesday, December 17, 2008

How To Make "Incognito mode" as default mode InChrome

Step I:
Right Click on the shortcut of Google Chrome & select ‘Properties’

Step II:
Then in the ‘Target’ field add “-incognito” in the end, it is without the quotes.

Example Path :
"C:\Documents and Settings\User\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" --incognito




Finally Click on OK

Format JSON String To JSON Structure

To Format JSON String to JSON Format .... go there


Tuesday, November 25, 2008

Google Search On SMS

Google Has Introduce Search Through SMS

Try it out! Simply send your search query by SMS to 9-77-33-00000 and it will send back results by SMS immediately.

For More Details

Wednesday, November 12, 2008

Google Introduce Voice And Video Chat

See and hear family and friends right inside Gmail

  • Chat more ways than ever from within Gmail

  • Look and sound your best with high quality audio and video

  • Get started easily -- all you need is a webcam
Click here

Tuesday, November 4, 2008

How to remove white space in column

SELECT LTrim(RTrim(Column_Name))AS Column_Caption FROM TableName

Wednesday, October 29, 2008

Microsoft Visual Studio 2010 Available For Download


Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from
Microsoft. Designed to address the latest needs of developers,
Visual Studio delivers key innovations in the following pillars:
  • Democratizing Application Lifecycle Management

  • Enabling emerging trends

  • Inspiring developer delight

  • Riding the next generation platform wave



For more information on Visual Studio 2010 and the .NET Framework 4.0 visit here

Courtesy


How To Block Back Button In Browser


<script type="text/javascript" language="javascript">
history.go(1);
</script>

Wednesday, October 22, 2008

Wednesday, October 15, 2008

How To Find the Time Difference Between Two Given Time


SELECT DATEDIFF(HOUR,'2008-10-14 18:30:32.800',getdate()) as TotalHours

Tuesday, September 30, 2008

how to omit some files from form authentication

<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

If u want to omit more than one files from form authentication then put all the file within on
common folder and replace the <location path="Default.aspx">

<location path="public/">, here public is the name of the folder

<location path="public/">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>

Friday, September 26, 2008

How To Replace Text With Image In Custom DataGrid Edit,Delete,Cancel



<asp:EditCommandColumn HeaderText="Edit" HeaderStyle-BackColor="#efeded"


CancelText="<img src='Images/icon_cancel.gif' alt='Cancel' style='border:0px' />"


EditText="<img src='Images/icon_edit.gif' style='border:0px' alt='Edit'/>"


UpdateText="<img src='Images/icon_save.gif' alt='Update' style='border:0px' />">


</asp:EditCommandColumn>


Friday, September 19, 2008

on datagrid edit how to focus on textbox


protected void dgAnnouncement_ItemCommand(object source, DataGridCommandEventArgs e)
{

switch(e.CommandName)
{
case "Edit":
dg.EditItemIndex = e.Item.ItemIndex;
.
.
fillurDataGrid
.
.
TextBox txtSub1 = (TextBox) dg.Items[e.Item.ItemIndex].Cells[0].FindControl("txtSubject");

// "Control differ according to the control you used within the DataGrid Column Here me used TextBox"

// "Cells[0] --> "Position Of The Column In The DataGrid"

// "FindControl("txtSubject") --> Control Id Which Within the Particular Cell

txtSub1.Focus();
}
}

Wednesday, September 17, 2008

What's the difference between TINYINT, SMALLINT, INT and BIGINT DataType In SQL SERVER

This datatype same is type but the differ from storage type,min and max values, the details as follows,

Data Type Min Value Max Value Storage Size
tinyint 0 255 1 byte
smallint -2^15 (-32,768) 2^15 - 1 (32,767) 2 bytes
int -2^31 (-2,147,483,648) 2^31 - 1 (2,147,483,647) 4 bytes
bigint -2^63 (-9,223,372,036,854,775,808) 2^63 - 1 (9,223,372,036,854,775,807) 8 bytes

Thursday, September 4, 2008

How To Get The Day Name From The Given Date Using C#

DateTime dt = DateTime.Parse("08/08/2001");

Response.Write(dt.DayOfWeek);

Wednesday, August 27, 2008

How To Get Month Name Form Date


Get Month Name From Given Date

SELECT DATENAME(MONTH,'08/15/1947')

sql server how to order by month,date


Order By Month

SELECT Emp_Name,CONVERT(varchar(11),DOB,113) as DOB FROM CV_DOB order By MONTH(DOB)


Order By Date

SELECT Emp_Name,CONVERT(varchar(11),DOB,113) as DOB FROM CV_DOB order By DAY(DOB)

Thursday, August 14, 2008

How To Remove Empty Rows In DataTable

int i = 0;
while (i <= datatableid.Rows.Count - 1)
{
if (datatableid.Rows[i]["ColumnName"].ToString().Trim() == string.Empty)
{
datatableid.Rows.RemoveAt(i);
}
else
{
i += 1;
}
}

Thursday, August 7, 2008

How To Count The Number Of Rows In The DataGrid

datagridname.Items.Count

Items

Gets a collection of DataGridItem objects that represent the individual items in the DataGrid control

How To Replace Null Value With The Custom Value

COALESCE ( expression [ ,...n ] )

Example :

SELECT COALESCE(FieldName,'0.00') FROM TableName;

If The Specified Field have null value it will be replace by 0.00 in the Result.

It's equivalent to Oracle NVL.

Friday, August 1, 2008

How To Set Max Length TextArea OnPaste


function maxLengthPaste(field,maxChars)
{
event.returnValue=false;
if((field.value.length + window.clipboardData.getData("Text").length) > maxChars)
{
return false;
}
event.returnValue=true;
}
Use OnPaste Went To Call This Function
onpaste="return maxLengthPaste(this,500)"


This Code Has Been Post By The Viewer As Comment

Thursday, July 31, 2008

How To Clear All The Controls In Form

function clrCtrls()
{
with(document.forms[0])
{
for(var i=0; i < elements.length; i++)
{
var e = elements[i];
if(e.type == "checkbox" e.type == "radio" ){e.checked = false;}
if(e.type == "text" e.type == "hidden"){e.value = "";}
if(e.type == "select-one"){e.selectedIndex = 0;}
}
}
return false;
}

Call This Fuction From any Event = "return clrCtrls()";
IE/Firefox Supproted

Wednesday, July 30, 2008

Live web portal to get information on traffic status

A new web portal to get live information on traffic status, directions and auto fares for cities Bangalore, Hyderabad and Chennai. The traffic police have launched a live traffic portal (Transport Information System) where you can find


1. Optimal routes between any two places in the city...
2. Auto-fares
3. Bus routes and stops, etc.


Check ->


Delhi


Chennai


Chennai Live Traffic


Bangalore


Hyderabad


pune

Wednesday, July 23, 2008

How to Capitalize the First Letter (Title Case) of All Words in a string in C#


To Make our string as TitleCase use ToTitleCase method of TextInfo class in
System.Globalization namespace that does exactly what we need

CultureInfo.CurrentCulture.TextInfo.ToTitleCase("place your string here");
output : Place Your String Here

Monday, July 21, 2008

How To Use The Order By Clause When Using UNION ALL Clause

SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'CA' ORDER BY au_lname
union all
SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'UT' ORDER BY au_lname


Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'union'.


To Over Come Problem use derived tables, think of these as a self-contained table, a bit like a temporary table within the query

SELECT * FROM (SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'CA' ORDER BY au_lname) AS TEMP_COL_1
UNION ALL
SELECT * FROM (SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'UT' ORDER BY au_lname) AS TEMP_COL_2,


when we want to use order by clause within the particular query then we need top else we will get the following error,
"
Msg 1033, Level 15, State 1, Line 1
The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.
Msg 1033, Level 15, State 1, Line 3
The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified."

Monday, April 28, 2008

How To Validate Email Id Using JavaScript

<html>
<head>
<script>
String.prototype.ValidateEmail = function (evt)
{
var eVal = new RegExp("\\w+([-+.\’]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
var chkVal = eVal.exec(this);
if(chkVal != null)
{
alert('Id Correct');
}
else
{
alert('Check Your Id');
}
</script>
</head>
<body>
<input type="text" id="txtEmail" width="30px" onblur="this.value.ValidateEmail();" />
</body>
</html>
ProgramDemo

Tuesday, April 15, 2008

How To Add Edit Delete Item In ListBox

This program used to add,edit and remove the item in the listbox control, this code can be used for both the serverside control and also for clientside control.

JavaScript Part:
Add Item To ListBox:

             function addItem()
{
var lst = document.getElementById('lstbox'); // listbox control id
var newItem = prompt("Enter New Item","Enter Value Here");
                      //Option object is created for every option in a selection
//new Option([text[, value[, defaultSelected[, selected]]]]) // Syntax
                      if(newItem == null)
{
return false;
}
else
{
lst.options[lst.length] = new Option(newItem,newItem,false,false);
return false;
}
}
Edit Item To ListBox:
             function editItem()
{
var lst = document.getElementById('lstbox'); // listbox control id
var selVal = lst.value;
if(selVal != "")
{
var newItem = prompt("Enter New Item",selVal);
if(newItem == null)
{
return false;
}
else
{
lst.options[lst.selectedIndex] = new Option(newItem,newItem,false,false);
return false;
}
}
else
{
alert('Select Item From The List To Edit ');
}
}
Remove Item For The Listbox

function rmItem()
{
var lst = document.getElementById('lstbox');// listbox control id
var selVal = lst.value;
if(selVal != "")
{
var msg = confirm("Do You Want To Remove ( "+selVal+" ) From The List");
if(msg == true)
{
lst.options[lst.selectedIndex] = null;
}
}
else
{
alert('Select Item To Remove From The List');
}
return false;
}




HTML Part

<div>

<select id="lstbox" multiple=multiple style="width:100px; overflow:auto;">

</select>

<input type="button" id="btnAdd" value="Add" onclick="return addItem();" />

<input type="button" id="btnEdit" value="Edit" onclick="return editItem();" />

<input type="button" id="btnDel" value="Delete" onclick="return rmItem();" />

</div>

Programe Demo

Sunday, April 13, 2008

How To Sort Numbers Using JavaScript

<html>
     <head>
           <title>
                Sorting Number Using JavaScript
           </title>
                 <script type="text/JavaScript" language="JavaScript">

                   
 Array.prototype.SrtNum = function()
                   {
                          return this.sort( function (a,b) { return a-b; } );
                   }


                   var arr = [5,9,1,10,8,4,2,7,3];
                   document.write("Before Sorting :"+arr+"<br />After                    Sorting :"+arr.SrtNum());
                   alert(arr=arr.SrtNum());

                     </script>
               
<head>
          <body>
     </body>
</html>

Program Demo

Wednesday, April 9, 2008

How To Create User Defined Tag In WebConfig

WebConfig
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="YourTagName" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.3300.0, Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
.
.
.
.
</configSections>
<appSettings>
.
.
.
</appSettings>
<YourTagName>
<add key="YourKeyName1" value="Xploredotnet"/>
<add key="YourKeyName2" value="adminpwd"/>
</YourTagName>

.
.
.
.
.
</configuration>



Code Behind
This is one of the way to access Custom Tag

string AdUrs,AdPwd;
AdUrs = ((System.Collections.Specialized.NameValueCollection)ConfigurationManager.GetSection("YourTagName"))["YourKeyName1"] +string.Empty;
AdPwd = ((System.Collections.Specialized.NameValueCollection)ConfigurationManager.GetSection("YourTagName"))["YourKeyName2"] + string.Empty;

Monday, April 7, 2008

Attributes Of Highly Effective Programmers - Quality Of A Developer - Self-criticism

Today I had come across two articles and I feel that its good and all the programmers should read this articles.I like to share this for my blog readers.I'm posting the abstract here, so through the orginal articles.

Top 5 Attributes of Highly Effective Programmers

  • Humility
  • Love of Learning
  • Detail-orientedness
  • Adaptability
  • Passion

The most important quality of a developer: Self-criticism

"Don't just implement the first design you come out with, but try and refine looking at it from different angles before to start writing code.

Don't just release the first piece of code you come out with, but do a self review and try to make it clearer and better.

The best developers/architects are the ones that always criticized their own work in order to make it better."

Wednesday, March 26, 2008

Simple Sorting Using C# - Descending


public class Sort
{
public static void Main()
{
int[] iArr = { 9, 4, 2, 7, 6, 1, 0, 5, 3, 8 };
int i=0, j, temp;
for (i = 0; i < iArr.Length; i++)
{
for (j = i + 1; j < iArr.Length; j++)
{
if (iArr[i] < iArr[j]) // Descending
{
temp = iArr[i];
iArr[i] = iArr[j];
iArr[j] = temp;
}
} Console.WriteLine("iArr["+i+"] =>" + "{0}", iArr[i]);
}
Console.ReadLine();
}
}

Wednesday, March 19, 2008

Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Solution
If Your Using Ajax Extension In Your Project Then you have to Add This following Dll To Your Project Bin folder System.Web.Extensions.Design.dllSystem.Web.Extensions.dll,because it may not be installed in the server where you are hosting your project,thats why you are getting the following Parser Error Message.

Line 63: </httpHandlers>
Line 64: <httpModules>
Line 65: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
Line 66: </httpModules>
Line 67:
Note:Add that Two Dll to your project, this two dll available in the following Path if you installed ajax extension in your system,
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

How To Set TextArea Max Length


<html>
<head>
<script type="text/javascript" language="javascript">
function chkLength(evt,len)
{
var str = document.getElementById(evt.id);
if(str.value.length < len)
{
return true;
}
else
{
return false;
}
}
</script>

</head>
<body>
<textarea id="txtArea" rows=5 cols=40 onkeypress="return chkLength(this,100);" ></textarea>
</body>


Program Demo
Note:IE Supported

Tuesday, March 18, 2008

Capture Mouse Click Event


<html>
<head>
<title>Capture Mouse Click Event</title>
<script language="javascript">
function noLeftClick()
{
switch (event.button)
{
case 1:
alert('You Clicked Left-Click ');
break;
case 2:
alert('You Clicked Right-Click.');
break;
}
}
document.onmousedown=noLeftClick
</script>
</head>
<body>
<h5>Click Any Were Within Browser</h3>
</body>
</html>
Program Demo

Note:IE Supported

Tuesday, March 11, 2008

Default values for bool, int, double, string, char, reference-type variables

TypeDefault Value


bool false


int 0


float 0


string null


char '\0'


ReferenceType null

Monday, March 10, 2008

How To Rename The Database In SQL Server

sp_renamedb
Changes the name of a database.

Syntax
sp_renamedb [ @dbname = ] 'old_name' , [ @newname = ] 'new_name'


[@dbname =] 'old_name'
              The current name of the database. old_name is sysname

[@newname =] 'new_name'
             The new name of the database. new_name must follow the rules for identifiers


Example:

CREATE DATABASE xample

sp_renamedb
'xample','Example'

How To Rename Column In Sql Server

Syntax:
sp_rename [ @objname = ] 'object_name' ,
                   [ @newname = ] 'new_name' ,
                   [ @objtype = ] 'object_type' ]
  
sp_rename
          Changes the name of a user-created object

'object_name'  
          Table ,View,column.

'new_name'
          New name which have to be replaced the old name.

[@objtype =] 'object_type'
         Specifying it's belong to which type like 
Column, Index etc.

Example:

use pubs

SP_RENAME
'DISCOUNTS.stor_id', 'STORID','COLUMN'

In this example Discounts is table name, stor_id is old_columnname, storid in new_columnname, column is an object type.

Thursday, March 6, 2008

Download Internet Explorer 8 Beta

Internet Explorer 8 takes the Web experience beyond the page and introduces a new way to seamlessly experience the power of the Web whether you are a Web developer writing to standards, or an end user discovering a new online service. This beta release is available to everyone, but is primarily for Web developers and designers to test the new tools, layout engine, and programming enhancements.

Courtesy:
Microsoft

How to select ROW in datagrid using Javascript


Program To Select Row In DataGrid Or Gridview Using JavaScript,Have To Use TemplateColumn,AutoGenerateColumns="false"
// JScript File JSdg.js
function rowBind()
{
var navRoot,node,dgRowid = null,tBody,rwVal;
var Prev = null,Curr = null;

if(document.all && document.getElementById)
{
navRoot = document.getElementById('dg');
// Can Be Used For Both DataGrid & GridView,
//Have To Give The Cleint ControlId.

if(navRoot != null)
{
tBody = navRoot.childNodes[0];

for(i=0;i<tBody.childNodes.length;i++)
{
node = tBody.childNodes[i];
if(node.tagName == "TR")
{
node.onmousedown = function()
{
dtRowid = this.rowIndex;
rVal = dtRowid+2;
if(dtRowid < 8)
{
rwVal = 'dg$ctl0'+ rVal+'$txtAuId';
}
else
{
rwVal = 'dg$ctl'+rVal+'$txtAuId';
}

var ctrl1 = document.getElementById(rwVal);
if(Prev != null)
{
node.parentElement.children[Prev].style.background = "#FFFFFF";
}
Curr = this.rowIndex;
if(Curr != null)
{
node.parentElement.children[Curr].style.background = "#D8E8FF";
Prev = Curr;
}
alert(ctrl1.value);
}
}
}
}
}
}

CodeBehind

SqlConnection Con = new SqlConnection(@"SERVER=YourSERVERNAME;DATABASE=PUBS;UID=sa;PWD=sa;");
SqlDataAdapter Da = new SqlDataAdapter();
DataSet Ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
Da = new SqlDataAdapter("Select * from Authors", Con);
Da.Fill(Ds);
dg.DataSource = Ds;
dg.DataBind();
}

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


<!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>Custom DataGrid</title>


<script type="text/javascript" language="javascript"
src="JavaScript/JSdg.js"></script>


</head>


<body onload="rowBind();">


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

<div>

<asp:DataGrid ID="dg" runat="server" AutoGenerateColumns="false" ShowHeader="false">

<Columns>

<asp:TemplateColumn>

<ItemTemplate>
<asp:TextBox ID="txtAuId" ReadOnly="true" runat="server"
Text='<%# Bind("au_id") %>'
Style="background-color: Transparent; border: 0px;">
</asp:TextBox>
</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

<asp:TextBox ID="txtAuName" ReadOnly="true" runat="server"
Text='<%# Bind("au_lname") %>'
Style="background-color: Transparent; border: 0px;">
</asp:TextBox>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

</asp:DataGrid>

</div>

</form>

</body>

</html>

Tuesday, March 4, 2008

Move Item Between ListBox


Program To Move Item Between ListBox (Select/Deselect All, Move Single Item, MultiSelect)


// JScript File(JSList.js)

var srclb,destlb;
var Flag ;
function moveAll(evt)
{

if(evt.id == 'btnSel' || evt.id == 'btnADitem')
{
srclb = document.getElementById('lboxSource');
destlb =document.getElementById('lboxdest');
}
else if(evt.id == 'btnDesel' || evt.id == 'btnRMitem')
{
srclb = document.getElementById('lboxdest');
destlb =document.getElementById('lboxSource');
}
if(srclb != null && destlb != null)
{
Flag = true;
while(Flag)
{
Flag = false;
for(var i=0;i<srclb.length;i++)
{
if(evt.id == 'btnADitem' || evt.id == 'btnRMitem')
{
if(srclb[i].selected)
{
exChange(i);
}
}
else if(evt.id == 'btnSel' || evt.id == 'btnDesel')
{
exChange(i);
}
}
}
}
}

function exChange(iVal)
{
destlb.appendChild(srclb[iVal].cloneNode(true));
srclb.removeChild(srclb[iVal]);
Flag = true;
}

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

<!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>ListBox</title>

<script type="text/javascript" language="javascript" src="JavaScript/JSList.js"></script>

</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:ListBox ID="lboxSource" SelectionMode="Multiple"
runat="server" Height="122px" Width="45px">
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
<asp:ListItem>D</asp:ListItem>
<asp:ListItem>E</asp:ListItem>
<asp:ListItem>F</asp:ListItem>
</asp:ListBox>
</td>
<td style="width: 31px">

<input id="btnDesel" title="DeselectAll" type="button"
style=" position:relative; left: 3px; width: 27px; top: 88px; height: 27px;"
onclick="moveAll(this);" value="««" />

<input id="btnRMitem" title="Remove Item" type="button"
style=" position:relative; left: 3px; width: 27px; top: 35px; height: 25px;"
onclick="moveAll(this);" value="«" />

<input id="btnADitem" title="Add Item" type="button"
style=" position:relative; left: 3px; width: 26px; top: -23px; height: 29px;"
onclick="moveAll(this);" value="»" />

<input id="btnSel" title="SelectAll" type="button"
style=" position:relative; left: 3px; width: 25px; top: -83px; height: 28px;"
onclick="moveAll(this);" value="»»" />

</td>
<td>
<asp:ListBox ID="lboxDest" SelectionMode="Multiple"
runat="server" Height="122px" Width="45px"></asp:ListBox>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>

Wednesday, February 27, 2008

How To Sort GridView Columns

public partial class GridView : System.Web.UI.Page
{
SqlConnection Con = new SqlConnection(@"Server=yourservername;Database=pubs;uid=userid;password=pwd;");
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();


protected void Page_Load(object sender, EventArgs e)
{
gv.DataSource = GetData();
gv.DataBind();
}

public DataTable GetData()
{
da = new SqlDataAdapter("Select * from authors", Con);
da.Fill(dt);
return dt;
}

protected void gv_Sorting(object sender, GridViewSortEventArgs e)
{
string stExp = e.SortExpression;
string stDir = string.Empty;
if (StDir == SortDirection.Ascending)
{
StDir = SortDirection.Descending;
stDir= "DESC";
}
else
{
StDir = SortDirection.Ascending;
stDir="ASC";
}
DataTable dt = GetData();
DataView dv = new DataView(dt);
dv.Sort = e.SortExpression + " " + stDir;
gv.DataSource = dv;
gv.DataBind();
}
public SortDirection StDir
{
get
{
if (ViewState["sortDirection"] == null)
{
ViewState["sortDirection"] = SortDirection.Ascending;
}return (SortDirection)ViewState["sortDirection"];
}
set
{
ViewState["sortDirection"] = value;
}
}
}

Tuesday, February 26, 2008

How To Create A Simple Shared Assembly in .NET

STEP 1 :

Start - > Microsoft Visual Studio 2005 - > Create Project - >New Project DialogBox - >Select

Class Library (Visual C#) add code in Your class file then complie it.

STEP 2:
Start - > Microsoft Visual Studio 2005 - > Visual Studio Tools -> Visual Studio 2005

Command Prompt

move on to project folder location

For Example:

If You Create A Project By Name Example, Your Project Saved in the following location

E:\Example\Example\bin\Debug> ,in Visual Studio 2005 Command Prompt type the following

E:>Cd E:\Example\Example\bin\Debug

create shared name file for your dll by typing the follwing line

E:\Example\Example\bin\Debug> sn -k userdefinedname.key

Example=E:\Example\Example\bin\Debug> sn -k Example.key

The Key Will Be Created Within Debug Folder in the name Example.key

STEP 3:

Goto project solution properties

Click "Signing" Tab (First From Buttom).

Check Sign the assembly

Choose a Strong Name Key File dropdown , then select browse "Example.key", after going to

Debug Folder,in the Select File Dialog Select All Files(File TYpe).

save and then Compile the project

STEP 4:

Start - > Microsoft Visual Studio 2005 - > Visual Studio Tools -> Visual Studio 2005

Command Prompt Example=E:\Example\Example\bin\Debug> gacutil /i .dll


STEP 5 :

After hosting the assembly just go to WINNT\Assembly folder and you will find your

assembly listed there

Thursday, February 21, 2008

Create Stored Procedure - What Is Stored Procedure Part - II

create a simple table Book, it contain 6 fields(columns) i which rowid in identity column which generated the number in sequence order.
CREATE TABLE BOOK
(
iROWID INT IDENTITY(1,1) PRIMARY KEY,
vBOOKNAME VARCHAR(20),
vAUTHOR VARCHAR(30),
vPUBLICATION VARCHAR(50),
vEDITION VARCHAR(20),
vPRICE NUMERIC(5,2)
)

CreatingProcedure For Inserting Data Into The Table

CREATE PROC PROC_ADD_BOOK
(
//declaration Part
@vBookName VARCHAR(20),
@vAUTHOR VARCHAR(30),
@vPUBLICATION VARCHAR(50),
@vEDITION VARCHAR(20),
@vPRICE NUMERIC(5,2)
)AS
BEGIN
INSERT INTO BOOK(vBOOKNAME,vAUTHOR,vPUBLICATION,vEDITION,vPRICE)
VALUES (@vBookName,@vAUTHOR,@vPUBLICATION,@vEDITION,@vPRICE)
END

Executing The Procedure
EXEC PROC_ADD_BOOK 'XML & ASP.NET','KRIK ALLAN EVANS','PEARSON EDUCATION','2002','555'

Wednesday, February 20, 2008

What Is Stored Procedure Part - I

Stored procedures have a segment of code which contains declarative or procedural SQL statement. A stored procedure is resided in the catalog of the database, we can invoke (call) it from a program, stored procedure or even from a trigger.


Stored Procedure contains sql statements like insert, update and delete. In addition stored procedure supports If and while statements.

Advantages:
Once we created Stored Procedure then it can be reused over and over again by multiple applications.

Stored Procedure increase the performance of the application because once it compiled successfully then it’s stored in database catalog. When applications call them, they generally execute faster when compared with un-compiled SQL Statements which are sent from the applications.

Network Traffic between application server and database server is also signification reduced when compared with un-compiled SQL Statements which are sent from the applications.

Syntax
CREATE PROC [ EDURE ] [ owner. ] procedure_name [ ; number ]
[ { @parameter data_type }
[ VARYING ] [ = default ] [ OUTPUT ]
] [ ,...n ]

[ WITH
{ RECOMPILE ENCRYPTION RECOMPILE , ENCRYPTION } ]

[ FOR REPLICATION ]

AS sql_statement [ ...n ]

owner:
Is the name of the user ID that owns the stored procedure. owner must be either the name of the current user or the name of a role that a current user is a member.

procedure_name:
Is the name of the new stored procedure, procedure name cannot exceed 128 characters.
@parameter:
Is a parameter in the procedure. One or more parameters can be declared in a CREATE PROCEDURE statement. The value of each declared parameter must be supplied by the user when the procedure is .A stored procedure can have a maximum of 2,100 parameters. Specify a parameter name using an at sign (@) as the first character.

OUTPUT:
Indicates that the parameter is a return parameter.

;number:
Is an optional integer used to group procedures of the same name so they can be dropped together with a single DROP PROCEDURE statement.

Tuesday, January 15, 2008

Try Visual Studio 2008


Microsoft Visual Studio 2008 provides an industry-leading developer experience for Windows Vista, the 2007 Microsoft Office system, and the Web.

90-Day Trial Downloads

Courtesy
microsoft

Friday, January 11, 2008

javascript function for invoking button click event

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>javascript function for invoking btnclick event</title>
<script language="javascript" type="text/javascript" >
function TrigButton()
{
if(window.event.keyCode == 13)
{
if(document.getElementById('txt').value.length > 0)
{
document.getElementById('bt').focus();
document.getElementById('bt').click();
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt" runat="server" Style="z-index: 105; left: 41px; position: absolute;
top: 141px" onkeydown="TrigButton()" ></asp:TextBox>
<asp:Button ID="bt" runat="server" Style="z-index: 107; left: 205px; position: absolute;
top: 142px" Text="Button" OnClientClick="javascript:alert('Button Triggered');" OnClick="bt_Click"/>
</div>
</form>
</body>
</html>