Monday, October 25, 2004

Keyboard Shortcuts in

Keyboard Shortcuts in

Comment/Uncomment Code Blocks - Ctrl + K + C / Ctrl + K + U
Show tip - Ctrl + Shift + Space
List Methods/Properties - Ctrl + Space
Build - Ctrl + Shift + B
Expand All Outlining - Ctrl + M + L
Toggle Outlining - Ctrl + M + M
Toggle Breakpoint - F9
Clear all Breakpoints - Shift + F9
Add Existing Item dialog - Shift + Alt + A
Add New Item dialog - Ctrl + Shift + A
Properties Window - F4
Code and Design Window - F7 and Shift + F7
Move to Next Bookmark - Ctrl + K + N
Move to Previous Bookmark - Ctrl + K + P
Selected text to Uppercase - Ctrl + Shift + U
Selected text to Lowercase - Ctrl + U
Toggle Bookmark on Current Line - Ctrl + K + K
Select Word Containing Cursor - Ctrl + W
Sizing Controls Height - Shift + Down / Ctrl + Shift + Down
Sizing Controls Width - Shift + Right / Ctrl + Shift + Right
Find Dialog - Ctrl + F
Solution Explorer Window - Ctrl + Alt + L
Toolbox - Ctrl + Alt + X
Navigate Backward - Ctrl + hyphen
Incremental Search - Ctrl + I
Clipboard Ring - Ctrl + Shift + V
Word-Wrap in Editor - Ctrl + R + R
Block Selection - Alt and Drag
Full Screen Mode - Shift + Alt + Enter

Thanks & Regard's

Ritesh Kumar Kesharwani
Software Engineer
Aditi Technology Pvt. Ltd.
Bangalore 560080 , India
Email -
Phone - +91- 80 - 23611300 / 301 Xtn. - 3216
Mobile - 0-9845657636

Wednesday, October 20, 2004

HTTP 1.1 500 Internal Server Error - Help!!

This fixed my problem too. I thought I was going to have to reload IIS and recreate all my virtual directories (and I have a ton on my development machine).

Here are those four magic lines (run at the Visual Studio.Net Command Line):
1) iisreset /stop
2) net user ASPNET /delete
3) aspnet_regiis -i
4) iisreset /start

Another Alternate Way

The fix below is for new web apps not opening and receiving the 'HTTP/1.1 500 Internal Server Error'
Check the following:
“My_Computer_Zone code group” value on the Web server? To achieve that, you should do the following:
- Go to “Administrative Tools”
- Open “Microsoft .Net 1.1 Configuration”
- In the new window, expand the “Runtime Security Policy”
- Expand “Machine”, then “Code Groups”, then “All_Code”.
- Right-Click on “My_Computer_Zone” and select properties.
- On the “Permission Set” tab, the selected value should be “Full Trust”
- If it is not, you should change the value to “Full Trust”.
- You can test again creating a new ASP.NET Web application

Wednesday, October 13, 2004

How to make a button default when enter key is hit (ASP.NET)

Enter Botton
Use this code :
Page.RegisterHiddenField("__EVENTTARGET", "btn_buttonID");
Write this line in your code behind, this line of code should be written in Page_Load event,
this line would always make btn_buttonID fire a click event when ever enter is pressed

Thursday, October 07, 2004

Default Button for a TextBox (Data entry screen) in ASP.NET

#) Default Button for a TextBox (Data entry screen) in ASP.NET
Sometimes I get annoyed when hitting the enter key in a TextBox (say login screen) resulting in undesired effects like the wrong Button being "clicked". After so many code tricks, I found the below method that allows you to specify a default Button to submit when the user hits the enter key in a TextBox.

When you press a key on your keyboard, the js OnKeyPress event is fired. This calls a function to which we pass the id of the button associated with the TextBox. The function gets a reference to the button and simuilates a mouse-click on the Button. We perform a browser detection because IE and Netscape have different event models. The function finally returns false so that the keypress event is cancelled (otherwise a second form submit will be raised). I tried this code with newer versions of IE 6.0/Netscape 7 it worked great!.
//client side js
function clickButton(e, buttonid){
var bt = document.getElementById(buttonid);
if (typeof bt == 'object'){
if (e.keyCode == 13){;
return false;
if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){
if (event.keyCode == 13){;
return false;
//code behind
TextBox1.Attributes.Add("onkeypress", "return clickButton(event,'" + Button1.ClientID + "')");

The code behind generates the following code:

This causes web control Button1 to be clicked when the enter key is hit inside TextBox1.
Hope this helps many!

Monday, October 04, 2004

How To Run Office Macros by Using Automation from Visual Basic .NET;EN-US;306682

Create the Visual Basic .NET Automation Client
Start Microsoft Visual Studio .NET. On the File menu, click New, and then click Project. Select Windows Application from the Visual Basic Projects types. Form1 is created by default.
Add a reference to the Access, Excel, PowerPoint, and Word object libraries. To do this, follow these steps:
On the Project menu, click Add Reference.
On the COM tab, locate Microsoft Word 10.0 Object Library or Microsoft Word 11.0 Object Library, and then click Select.NOTE: If you are using Microsoft Office XP and you have not already done so, Microsoft recommends that you download and then install the Microsoft Office XP Primary Interop Assemblies (PIAs). For additional information about Office XP PIAs, click the article number below to view the article in the Microsoft Knowledge Base:
328912 INFO: Microsoft Office XP PIAs Are Available for Download
Repeat the previous step for the Access, Excel, and PowerPoint object libraries.
Click OK in the Add References dialog box to accept your selections. If you receive a prompt to generate wrappers for the libraries that you selected, click Yes.NOTE: If you receive an error message when you reference the Access 10.0 object library, see the "Troubleshooting" section.

On the View menu, click ToolBox. Add a combo box and a button to Form1.
Double-click Button1 to generate a definition for the button's Click event handler.
Paste the following code in the Button1_Click procedure:
Select Case ComboBox1.SelectedItem

Case "Access"

Dim oAccess As Access.ApplicationClass

'Start Access and open the database.
oAccess = CreateObject("Access.Application")
oAccess.Visible = True
oAccess.OpenCurrentDatabase("c:\db1.mdb", False)

'Run the macros.
oAccess.Run ("DoKbTest")
oAccess.Run("DoKbTestWithParameter", "Hello from VB .NET Client")

'Clean-up: Quit Access without saving changes to the database.
oAccess.DoCmd().Quit (Access.AcQuitOption.acQuitSaveNone)
System.Runtime.InteropServices.Marshal.ReleaseComObject (oAccess)
oAccess = Nothing

Case "Excel"

Dim oExcel As Excel.ApplicationClass
Dim oBook As Excel.WorkbookClass
Dim oBooks As Excel.Workbooks

'Start Excel and open the workbook.
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBooks = oExcel.Workbooks
oBook = oBooks.Open("c:\book1.xls")

'Run the macros.
oExcel.Run ("DoKbTest")
oExcel.Run("DoKbTestWithParameter", "Hello from VB .NET Client")

'Clean-up: Close the workbook and quit Excel.
oBook.Close (False)
System.Runtime.InteropServices.Marshal.ReleaseComObject (oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject (oBooks)
oBooks = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject (oExcel)
oExcel = Nothing

Case "PowerPoint"

Dim oPP As PowerPoint.ApplicationClass
Dim oPresSet As PowerPoint.Presentations
Dim oPres As PowerPoint.PresentationClass

'Start PowerPoint and open the presentation.
oPP = CreateObject("PowerPoint.Application")
oPP.Visible = True
oPresSet = oPP.Presentations
oPres = oPresSet.Open("c:\pres1.ppt", , , True)

'Run the macros.
oPP.Run ("'pres1.ppt'!DoKbTest")
oPP.Run("'pres1.ppt'!DoKbTestWithParameter", "Hello from VB .NET Client")

'Clean-up: Close the presentation and quit PowerPoint.
System.Runtime.InteropServices.Marshal.ReleaseComObject (oPres)
oPres = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject (oPresSet)
oPresSet = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject (oPP)
oPP = Nothing

Case "Word"

Dim oWord As Word.ApplicationClass

'Start Word and open the document.
oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open ("C:\Doc1.doc")

'Run the macros.
oWord.Run ("DoKbTest")
oWord.Run("DoKbTestWithParameter", "Hello from VB .NET Client")

'Quit Word.
System.Runtime.InteropServices.Marshal.ReleaseComObject (oWord)
oWord = Nothing

End Select

On the View menu, click Designer and double-click Form1 to generate a definition for the form's Load event.
Paste the following code in the Form1_Load procedure:
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
Dim a As String() = {"Access", "Excel", "PowerPoint", "Word"}
ComboBox1.SelectedIndex = 0

Add the following code to the top of Form1.vb:
Imports Access = Microsoft.Office.Interop.Access
Imports Excel = Microsoft.Office.Interop.Excel
Imports Word = Microsoft.Office.Interop.Word
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint

Run and Test the Automation Client
Press F5 to run the application.
Select an Office application from ComboBox1, and then click Button1. The Office application that you selected is started and the DoKBTest and DoKBTestWithParameter macros are executed.
When you reference the Access 10.0 object library in a Visual Basic .NET project, you may receive an error message that states that conversion of the library to a .NET assembly failed. For additional information about how to resolve this problem so that you can successfully reference the Access 10.0 object library, click the article number below to view the article in the Microsoft Knowledge Base:
317157 PRB: Errors When Referencing the Microsoft Access 10.0 Type Library