Add Event Listener To A TextBox

<html>
<head>
<title>Demo</title>
<script type=”text/javascript”>
function textChanged(elm)
{
alert(elm.value);
}

onload = function()
{
var elm = document.getElementById(“mytextbox”);
elm.onchange = new Function(‘textChanged(this)’);
}
</script>
</head>
<body>
<input id=”mytextbox” type=”text”/>
</body>
</html>

SQL Types In SYSOBJECTS

The query:

 

select 

distinct type from sysobjects

FN: Scalar Valued Functions
P: Stored Procedures
U: Tables
TF Table Valued Functions

How to delete all of the same type?

use

mydb –replace by your own db name

GO

declare

@procName sysnamedeclare

someCursor cursor FORselect

name from sysobjects where type = ‘P’ AND objectproperty(id, ‘IsMSShipped’) = 0 order by name ascopen

someCursor

fetch

next from someCursor into @procName

while

@@FETCH_STATUS = 0

begin

 

exec(‘drop proc ‘ + @procName)

 

fetch next from someCursor into @procName

end

close

someCursor

deallocate

someCursorgo

 

 

Displaying Paging In ASP.Net

            GridViewRow pager = SearchResultsGridView.TopPagerRow;

            if (pager != null)
            {
                int pageCount = PageCount; // SearchResultsGridView.PageCount;
                int pageSize = SearchResultsGridView.PageSize;
                int columnCount = 10;

                if (pageCount > 1)
                {
                    Label pagerLabel = (Label)pager.Cells[0].FindControl("PagerLabel");
                    pagerLabel.Text = pagerLabel.Text.Replace("<transactions>", ResultCount.ToString());
                    pagerLabel.Text = pagerLabel.Text.Replace("<start>", (((CurrentPage) * SearchResultsGridView.PageSize) + 1).ToString());
                    pagerLabel.Text = pagerLabel.Text.Replace("<end>", (((CurrentPage + 1) * SearchResultsGridView.PageSize)).ToString());
                    PlaceHolder pagerPlaceHolder = (PlaceHolder)pager.Cells[0].FindControl("PlaceHolder1");
                    bool breakLoop = false;

                    if (pagerPlaceHolder != null)
                    {
                        Table myTable = new Table();
                        int rowCount = (pageCount / columnCount) + (((pageCount % columnCount) == 0) ? 0 : 1);

                        for (int row = 0; row < rowCount; row++)
                        {
                            int firstPageInRow = row * columnCount;
                            int lastPageInRow = ((firstPageInRow + columnCount - 1) < pageCount) ?
                                                 (firstPageInRow + columnCount - 1) : pageCount - 1;
                            TableRow myRow = new TableRow();

                            for (int column = 0; column < columnCount; column++)
                            {
                                // build the row out of the pageCount for the column
                                TableCell myColumn = new TableCell();
                                int startingRecord = (row * columnCount * pageSize) + (column * pageSize) + 1;
                                int endingRecord = (row * columnCount * pageSize) + (column * pageSize) + pageSize;

                                if (endingRecord > ResultCount)
                                {
                                    endingRecord = ResultCount;
                                    breakLoop = true;
                                }

                                string pageLabel = startingRecord + " - " + endingRecord;
                                int page = (row * columnCount) + column;

                                if (page == CurrentPage)
                                {
                                    // display a Label instead of a LinkButton
                                    Label label = new Label();
                                    label.Text = pageLabel;
                                    //label.ID = "Page" + (page + 1).ToString();
                                    myColumn.Controls.Add(label);
                                }
                                else
                                {
                                    // diplay a LinkButton for the page
                                    LinkButton button = new LinkButton();
                                    button.Text = pageLabel;
                                    button.CommandName = "Page";
                                    button.CommandArgument = (page + 1).ToString();
                                    //button.ID = "Page" + (page + 1).ToString();
                                    myColumn.Controls.Add(button);
                                }

                                myRow.Cells.Add(myColumn);

                                if (breakLoop)
                                {
                                    break;
                                }
                            }

                            myTable.Rows.Add(myRow);

                            if (breakLoop)
                            {
                                break;
                            }
                        }

                        pagerPlaceHolder.Controls.Add(myTable);
                    }

                    pager.Visible = true;
                }
                else
                {
                    pager.Visible = false;
                }
            }

Loop Through A Comma Delimited String In SQL

DECLARE @Items VARCHAR(1000)
SET @Items = ‘A,B,CD,E,FGH,KL,MNOP,QRSTU,V,W,XYZ’
DECLARE @Item VARCHAR(50)
DECLARE @Pos INT
DECLARE @Loop BIT
SELECT @Loop = CASE WHEN LEN(@Items) > 0 THEN 1 ELSE 0 END
WHILE (SELECT @Loop) = 1
BEGIN
SELECT @Pos = CHARINDEX(‘,’, @Items, 1)
IF @Pos > 0
BEGIN
SELECT @Item = SUBSTRING(@Items, 1, @Pos – 1)
SELECT @Items = SUBSTRING(@Items, @Pos + 1, LEN(@Items) – @Pos)
END
ELSE
BEGIN
SELECT @Item = @Items
SELECT @Loop = 0
END
END