Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

How fast can you create a single-page, coding-free, AJAX-enhanced, Linq-driven Web application from scratch in VS 2008v2/VWD? Very fast, I'll bet.

I've prepared these instructional steps. Your challenge is to follow them closely and report back how many minutes/seconds it took. You only get one shot (after that you're not a newbie).

Please report any errors, bugs, missing steps, troublespots, or ways to make this shorter. The process bogs somewhat in the Create a Database section but mainly suffers in the Configure the ListView Columns section. (I'm not sure why the column alignment goes out of whack and needs repair.)

Anyway, have fun and let me know?

Prepare the Project

  1. In VS 2008b2, create a new Web site (File > New Web Site > ASP.NET Web Site).
  2. Delete the Default.aspx that uses code-behind.
  3. Add a new page called Default.aspx (File > New File > Web Form > (Uncheck Place code in separate file) > Add).

Create the Database

  1. Add a database into the App_Data folder (File > New File > SQL Database > Add).
  2. In Server Explorer, select the Tables node (Data Connections > Database.mdf > Tables)
  3. Add a new table (Data > Add New > Table).
  4. Add an ID column. (Column name [id] > Data Type [int] > Identity Specification > (Is Identity) > Yes).
  5. Set ID as the primary key. (Table Designer > Set Primary Key)
  6. Add a Title column. (Column name [Title] > Data Type [varchar(50)])
  7. Add a Description column. (Column name [Description] > Data Type [varchar(300)])
  8. Save the Table Designer (File > Save Table1 > OK).
  9. Close the Table Designer.

Create a LINQ to SQL Class and DataContext

  1. In Solution Explorer, add a LINQ to SQL Class to the App_Code folder (File > New File > LINQ to SQL Classes > OK)
  2. If DataClasses.dbml isn't already open, open it.
  3. Switch to Server Explorer.
  4. Drag Table1 from Server Explorer and drop it on the left-hand pane (the Object Relational Designer).
  5. Save DataClasses.dbml and close the designer.

Configure the LinqDataSource

  1. Open the ASP.NET page in Design view.
  2. From the Toolbox, drag a LinqDataSource control and drop it on the page.
  3. In the LinqDataSource Smart Tasks, click Configure Data Source.
  4. Choose DataClassesDataContext as the context object and click Next.
  5. Click Finish.
  6. On the LinqDataSource Smart Tasks, select Enable Delete, Enable Insert, and Enable Update.

Configure the ListView

  1. From the Toolbox, drag a ListView control and drop it on the page.
  2. From the Smart Tasks, choose the data source LinqDataSource1.
  3. From the Smart Tasks, click Configure ListView.
  4. Select Grid, Colorful, and enable Editing, Inserting, Deleting, and Paging.
  5. Click OK.

Configure the ListView Columns

  1. From the ListView's Smart Tasks, set the Current View to AlternatingItemTemplate.
  2. In Design view, put your mouse in the ID column header.
  3. Right-click, and from the context menu click Delete > Delete Columns.
  4. From the Smart Tasks, set the Current View to EditItemTemplate.
  5. In the Title column, delete idLabel1.
  6. Move the two Textbox controls one column to the left.
  7. From the Smart Tasks, set the Current View to ItemTemplate.
  8. In the Title column, delete idLabel.
  9. Move TitleLabel and DescriptionLabel one column to the left.
  10. From the Smart Tasks, select SelectedItemTemplate.
  11. From the Title column, delete idLabel.
  12. Move TitleLabel and DescriptionLabel one column to the left.

Configure ASP.NET AJAX

  1. From the Toolbox, drag an AJAX ScriptManager control and drop it above the ListView control.
  2. Drag an UpdatePanel and drop it to the right of the ListView control.
  3. Select the ListView control and drop it inside the Update Panel.

Run and Test the Page

  1. Browse to the page.
  2. Add a title and description.
  3. Click Insert.

Hey, playing with this new stuff sure beats working for a living!

 

Published Tuesday, August 07, 2007 2:10 PM by Ken Cox [MVP]

Comments

# Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page - WebLog of Ken Cox

Pingback from  Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page - WebLog of Ken Cox

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 2:59 PM by Dave T

Can you provide a screenshot of your result?

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 3:42 PM by Uwe

Can you provide a test website with your results!

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 4:12 PM by Daniel

Skim 15 minutes off this by creating the Linq-to-SQL first, then calling CreateDatabase() to create the db...

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 4:13 PM by FransBouma

Why is everybody in such a rush? I mean, sure writing unnecessary code is useless and a waste of time, though stepping through steps which produce a page which won't be used in such a state in any production app is IMHO not realistic.

Yes, RAD is sometimes OK, but let's not overreact. In most cases, namely at work for real software, RAD is overrated.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 4:35 PM by Kirk Allen Evans

Booyah!  6 minutes, 22 seconds, and I've never touched the LINQ stuff at all... this was my first time ever touching it.  Probably could've shaved a few seconds if I had read through all of the directions before starting the exercise.

Great job, Ken, showing how quickly you can write real-world web applications!

# Write an AJAX-Enabled Web Page with Sorting, Paging, Inserting, Editing, Updating, Deleting... in 6 Minutes?!?

Tuesday, August 07, 2007 4:40 PM by Kirk Allen Evans' Blog

Ken Cox has a great web post, " Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page " that shows the power

# Write an AJAX-Enabled Web Page with Sorting, Paging, Inserting, Editing, Updating, Deleting... in 6 Minutes?!?

Tuesday, August 07, 2007 4:48 PM by Noticias externas

Ken Cox has a great web post, " Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page " that shows

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, August 07, 2007 5:26 PM by Mike P.

How fast is macromedia studio 8? Betcha its probably faster and looks a hell of a lot nicer. I mean if RAD is your thing. I doubt Visual Studio is your tool.

# MSDN Blog Postings » Write an AJAX-Enabled Web Page with Sorting, Paging, Inserting, Editing, Updating, Deleting... in 6 Minutes?!?

Pingback from  MSDN Blog Postings  » Write an AJAX-Enabled Web Page with Sorting, Paging, Inserting, Editing, Updating, Deleting... in 6 Minutes?!?

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, August 08, 2007 1:39 PM by Mueller

Nice post, thanks!

Is anybody else starting to get annoyed by Frans Bourma's marketing campaign? He won't sell llblgen licenses by permanently whining about linq or by implying every other post that mattwarr is incompetent or scottgu a liar.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, August 08, 2007 1:55 PM by andrew

cool walkthrough.. editing the id completely out was a little cumbersome though

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Thursday, August 09, 2007 7:06 PM by simone_b

Mueller, whether Frans is trying to sell his product or not he's right that you won't go far on a real project with this approach. It's not about the time it takes to show data in a table. Add logging, add transaction management, remove logging when in production, and what about testing? This is cool as long as you need to develop a 2-day application.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Friday, August 10, 2007 5:46 PM by snelldl

17 minutes. Once my machine caught up with me, I went pretty fast.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, August 22, 2007 4:05 PM by dap

Great walkthrough answers many questions

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, July 29, 2008 2:42 AM by D_Rivers

I love this stuff... Linq rocks. Today was the first day I had time to play with it... Awesome.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, January 14, 2009 12:12 PM by Nathan

Ken, great walk through!

In the "Configure the ListView Columns" section the steps indicate that I can edit the ListView control at design time.  I had to edit the control in source view because I received a message that said "Design time editing is not supported for this template."

Is there an update to this control that will allow editing the control at design time?

I'm using VS Web Developer Express 2008 not the full blown VS 2008v2/VWD.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Friday, June 12, 2009 6:45 AM by Jabran

yes, it was never so fast. great

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Tuesday, July 07, 2009 2:37 AM by mohan

i can't understand steps in Create a LINQ to SQL Class and DataContext. pls clarify that.

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, December 09, 2009 11:08 AM by jon

if you get errors when inserting new values due to identity problems, make sure that under your LINQ configuration (the pretty graphical interface with all your tables) you defined the identity field of your table as Auto Generated Value = True (under its Properties)

# re: Speed Test: A No-Code LINQ-Based ASP.NET 3.5 Page

Wednesday, October 26, 2011 3:18 PM by ishik

Thank you for step by step linq

Leave a Comment

(required) 
(required) 
(optional)
(required)