Those who knows asp.net mvc, might already knows the power of scaffolding...
With VS.Net 2013 we will have scaffold template included for asp.net web forms. By scaffold template you can generate a boilerplate code for asp.net web forms in a min.
The Web Forms scaffold generator can automatically build Create-Read-Update-Delete (CRUD) views based on a model.
Step by Step example of using scaffold template inside asp.net web forms to generate CRUD operations.
Download VS.Net 2013 Express Preview
Create Asp.net WebForm Project
Add Model Class and named it as "Product.cs" (Right click Model class and Add new class)
- [ScaffoldColumn(false)] will not generate any presentation code for that field
- [StringLenght(25)] will limit product name upto 25 characters only.
- [DataType(DataType.Currency)] will limit to enter only proper currency value.
Right click on model class and add scaffold for Product class.
Click on Add button as shown in figure to "Generates Asp.net Web Forms pages for read/write operations based on a given data model."
Select Model class as "Product.cs", Since we haven't created or have any data context class, select "Add new data context" and Click on "Add" button.
If you wish you can change name of your data context class. For this demo purpose I am keeping everything to default generated by VS.Net. Press "OK" button.
You will noticed that VS.Net 2013 has generated new data context file inside model folder and has also created CRUD operations for Product class.
Run the application and enjoy the boilerplate code... You will also noticed that web forms project has extension-less url and also has responsive design using Twitter bootstrap out of the box...
Type the url: /Product notice it is extension-less url and
Click on "Create new" link and create new product
Data Entry few product. Notice fancy validation on entering wrong values. "Everything is out of box, you don't need to write a single line of code to make this working... Isn't that cool"
Similarly you can edit record, delete record...
Hope you enjoyed this post...