Pages

Saturday, August 29, 2009

Basic SQL System Stored Procedures to be known by every Developer

There are large number of System Stored Procedures. Here are few stored procedures that should be known by every developer who work with Databases. And these stored procedures will be very handy at times(Particularly for me.My favorites :) ).


sp_Help:

Gives the structure of the table.

Syntax: sp_Help

Eg: sp_Help 'dbo.tblProduct'



sp_Helptext:

Gives the definition of the objects like Stored Procedures(both user defined and system defined), Triggers, Functions and etc.

Syntax: sp_Helptext

Eg: sp_Helptext 'dbo.sp_tblProduct_Insert'



sp_Depends:

Gives all the Stored Procedure and View associated with the Table.

Syntax: sp_Depends

Eg: sp_Depends 'dbo.tblProduct'



sp_Spaceused:

Gives information on the size database objects.

Syntax: sp_Spaceused

Eg: sp_Spaceused 'dbo.tblProduct'


I can assure you these System Stored Procedures will help you in Development.

Please let me know your thoughts. Have a wonderful time.

Thursday, August 27, 2009

Change Focus for TextBoxes using Javascript

In most of the real time project there will be requirement to change focus of the TextBox from one to another dynamically, instead of clicking the TextBoxes. The ideal example in this case would be Phone Number Text Boxes in the US format(000-000-0000). Consider there were three TextBoxes. It wil be irritating for the end user to click each text box and then type numbers.

So here, on every keyboard press event ("onkeypress") we capture the event and check for the length of the TextBox in the changeFocus() Javascript function. Again the browser compatibility issue raises its head and its handled in its own way. This is so simple to implement. Here is the code snippet.

Javascript Function:

//Change Focus for the Phone TextBox

function changeFocus(textbox1,textbox2)
{
var browserName=navigator.appName;
if (browserName=="Netscape")
{
if(textbox1.value.length >= 2)
{
textbox2.focus();
}
}
else if(browserName=="Microsoft Internet Explorer")
{
if(textbox1.value.length == 3)
{
textbox2.focus();
}
}
else
{
if(textbox1.value.length == 3)
{
textbox2.focus();
}
}
return true;
}

//End of Change Focus for the Phone TextBox


The ASP.NET(Vb) File Code:-

You can add this code in the Load Event of the Page.

Me.TxtCellPhone1.Attributes.Add("onkeypress", String.Format("javascript:return changeFocus({0},{1});", Me.TxtCellPhone1.ClientID, Me.TxtCellPhone2.ClientID))
Me.TxtCellPhone2.Attributes.Add("onkeypress", String.Format("javascript:return changeFocus({0},{1});", Me.TxtCellPhone2.ClientID, Me.TxtCellPhone3.ClientID))

Here no need to add an event for TxtCellPhone3 TextBox.

Let me know your Thoughts. Happy Coding.

Tuesday, August 25, 2009

Diable Browser Back Button

I have gone mad for getting my browser back button disabled in one of my projects. And at last arrived at this solution:

function disableBrowserBackBtn() { window.history.go(1) }
disableBrowserBackBtn();
window.onload = disableBrowserBackBtn();
window.onpageshow = function(evt) { if (evt.persisted) disableBrowserBackBtn() }
window.onunload = function() { void (0); disableBrowserBackBtn(); }

You have to just add the Script in the pages you want to disable the browser back button.

But this is just bluffing the user, using the the javascript code window.hsitory.go(-1) ->Redirecting to previous page.

For the perfect solution you have to open a new pop-up window with no navigation toolbar.

Please let me know your comments....Have a good day.