Dec 13, 2014

Some useful shortcuts in Visual Studio

Hi the keyboard shortcuts are

F4

F4 is used to show property window.

F5 & Ctrl-F5

F5 is used to start your project in debug mode.
Ctrl-F5 is used to start your project without debug mode.

F6 / Shift-F6 / Ctrl-Shift-B

These are used to build the project or solutions.

F7 & Shift-F7

F7 is used to show code view of your webpage.

Shift-F7 is used to show design view of your webpage.

Ctrl-Shift-A

Ctrl-Shift-A is used to add new item to your project.

Alt-Shift-A

Alt-Shift-A is used to add existing item to your project.


Ctrl-K + Ctrl-C

Ctrl-K + Ctrl-C is used to do comment a selected block of code.

Ctrl-K + Ctrl-U

Ctrl-K + Ctrl-U is used to do uncomment a selected block of code.

Ctrl-M + Ctrl-O

Ctrl-M + Ctrl-O are used to collapse all code to definitions.

Ctrl-M + Ctrl-P

Ctrl-M + Ctrl-P are used to expand all code.


Ctrl-K + Ctrl-S

Ctrl-K + Ctrl-S are used to surround a block of code to a specific block or control.

Alt-Shift-Arrow (Right, Left, Bottom, Top)

Alt-Shift-Arrow (Right, Left, Bottom, Top) are used to copy, paste, write vertically.

Ctrl-(+) + Ctrl-.

Ctrl-(+) + Ctrl-. Is used to display SmartTag under the red line that provides the options for fixing the code problem.

F12

F12 is used to navigate to the definition of an instance, variable, class etc.

Ctrl-Shift-F

Ctrl-Shift-F is used to find all the occurrences of a string with in entire solution and display find result window.

Ctrl-F

Ctrl-F is used to find a string in the current document, project and all open documents one by one.

Ctrl-H

Ctrl-H is used to replace a string by a new string in current document, project and entire solution as you want to replace.

Ctrl-Alt-L


Ctrl-Alt-L is used to show solution explorer.



I hope you will enjoy these shortcut keys.

Please follow for full details, click on below link


Thanks
Rajkumar Palnati

Dec 12, 2014

Some Useful Stuff in Dot Net

1. How to check UserId available in database or not ?

A : First design the page like 


Source Page, 



Code behind, 


 protected void Button1_Click(object sender, EventArgs e)


        {
            SqlConnection con = new SqlConnection(str);
            con.Open();
            SqlCommand cmd = new SqlCommand("select count(*) from test where testid=" + TextBox1.Text.Trim(), con);
            int i = Convert.ToInt32(cmd.ExecuteScalar());
            if (i > 0)
            {
                Label3.Text = "This UserId is already existed";
            }
            else
            {
                Label3.Text = "This User Id not existed";
            }

        }

------------------------------------------------------------------------

2. How to find the last 2 characters in a given input string 

Code behind,


string str=txtinput.Text.Trim().Substring(Math.Max(0,txtinput.Text.Trim().Length-2));

---------------------------------------------------------------------------------