Why to modify control code snippet?
Following are some reason to modify the control code snippet
- Want some Hungarian notation or prefix for controls. Then it can be set in the code snippet. There is no need to type txt in "txtArea" , chk in "chkAllow", opt in "optMale" etc.
- Want some properties to appear when the control is created. Like runat="server" etc.
How to modify code snippet for control?
Step1: Open visual studio 2010
In Visual studio 2010, Select Tool from menu bar and then select "Code snippets Manager". This will open code snippet manager dialog box.
Step2: Code snippet manager dialog box
In code snippet manager select "HTML" as language. And then expand ASP.NET node displayed in the left pane.
Select checkbox item under the "ASP.NET" node and copy the path displayed besides the "Location" label.
Step3: Open "Run" window from startup
In run paste the paths copied in the previous step
Press enter and the requested snippet will be opened in visual studio. (You can open it in any IDE) Select "NO" when following popup appears.
Step4:Edit the snippet
Edited the snippet (Edited section is highlighted with a box)
Step5: Create new project/solution
Open the .aspx page of the new project as show below.
Type "check" and intellisense will appear, select "checkbox" and then press tab twice
Finally when you will insert the checkbox using snippet then always modified control will be created.
Same way I modified the snippet for textbox and inserted textbox using insert snippet. As shown below