RSS 2.0
# Monday, February 14, 2011

You know, I like simple little nice enhancements that make things easier.  Like the extension manager in Visual Studio restarting the project you were in after doing an update that requires a restart of Visual Studio.  Phil Haack just blogged about the version 1.1 of NuGet being released.  I’ve applied plenty of extension updates and of course Visual Studio handled restarting properly.  Just wanted to make note of how those little things make a big difference in the user experience.

Technorati Tags:
Monday, February 14, 2011 9:06:29 PM UTC  #    Comments [0] -
Visual Studio
# Thursday, January 20, 2011

Ok, well, for whatever reason, I wasn’t able to get the old project working with MvcScaffolding after updating to the RTM of MVC 3.  I had even run the upgrade tool.  We are and were dealing with beta software, sometimes that’s what happens.  Thankfully we weren’t too far along.  So, what I’ve done is created a new project and simply added all our model classes to the new project.

I then reinstalled our packages from NuGet:

image

image

Now we will do some scaffolding.

image

Change the default route to point to our Recipe Controller:

image

And wa-la, we’ve got a running application.

image

Since we never defined a connection string for the application, it created a new database in our Sql Server Express instance with the fully qualified name of the context class.

image

So you can see that outside of create our model classes, everything else can be automated and done very quickly.  Understanding what is actually going on is important, so next we’ll look in more detail at the files that were created.

Technorati Tags: ,
Thursday, January 20, 2011 10:52:44 PM UTC  #    Comments [0] -
.NET | Entity Framework | mvc | SQL Server | Visual Studio
# Thursday, November 11, 2010

Microsoft is giving away another free ebook!  This one is Moving to Microsoft Visual Studio 2010.

The book contains three parts:

  • Moving from Visual Studio 2003
  • Moving from Visual Studio 2005
  • Moving from Visual Studio 2008

Each part will help developers understand how to use Visual Studio 2010 to create many different types of applications and unlock their creativity independently of the version they are using today. This book will focus on Visual Studio, but we’ll also cover many language features that make the move even more interesting.
Each part will follow a similar approach and will include these chapters:

  • “Business Logic and Data”
  • “Designing the Look and Feel”
  • “Debugging the Application”
Technorati Tags:
Thursday, November 11, 2010 3:49:25 AM UTC  #    Comments [0] -
Microsoft | Visual Studio
# Monday, August 23, 2010

Microsoft released a beta of Lightswitch the other day.  Here I’m going to do a run through of creating a simple application. I’m doing this without having read much of anything about Lightswitch.

image

So, choosing this project template and after a bunch of churning, we get presented with this:

image

Since this is a fresh new application, we’ll choose to create a new table.  Doing so, we are presented with this:

image

Let’s just make a simple contact table and later build from that.

image

Notice that there are properties associated with the entity that we are creating.  I’m guessing the properties on the generated class will be decorated with attributes from the DataAnnotations namespace.

For the State property, we’ll add a “Choice List” with a few states in the USA:

image

image

Next we’ll create a “screen” from the “Add” bar.

image

Before we do, let’s rename the “table” to “Contacts”

image

We’ll choose “List and Details Screen”, change the screen name to “ContactListDetails” and choose “Contacts” for the screen data:

image

We are now presented with this:

image

Ok, so let’s build it and run to see what we get.

image

Not bad for about 10 minutes worth of work.

Next we’ll play around with this form and see what else we can do.  There was no code written for this at all.  We’ll dig into the files that are created with this project and see what is generated behind the scenes.  Switching from the Logical View to the File View, we can see that there is a hierarchy of files to look into.

Technorati Tags: ,,
Monday, August 23, 2010 3:00:56 AM UTC  #    Comments [0] -
.NET | LightSwitch | Visual Studio
# Sunday, July 25, 2010

Is the filter box in the Add Reference dialog.  Hallelujah!  What took sooo long?

image

Technorati Tags:
Sunday, July 25, 2010 12:43:05 PM UTC  #    Comments [0] -
Visual Studio
# Friday, May 21, 2010

Was working on the beginnings of a new project and building up a database just by using a file based database connecting with SQL Express.  When it’s actually deployed, it’ll be on a full SQL Server, so I scripted the database and executed the script on my local SQL Server.  The database already had the membership tables built in.  I also knew that I’d not be connecting to it via sa for obvious reasons, so I created a stripped down SQL account to connect with. Good enough.

So, modify web.config to change the connection string and the each of the provider entries to point to the new connection string.  Simple enough.

Run the application connecting to the server and greeted with this:

The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'.  However, the current database schema is not compatible with this version.  You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.

Things that make you go hmmmm…

headscratch 

So, I quickly Google with Bing and find this. http://forums.asp.net/p/985097/1267872.aspx.  Ok, fair enough, I did just script it rather installing it.  So I ran aspnet_regsql to remove everything then ran it again to add it all.  Ok, the schema table that’s mentioned in that article is populated and anything else that might get missed from scripting should be there as well, right?  Right … well…

Run it again and same error.  Ok, change the connection to use sa and run again.  Works.  Ok, permissions issue.  Originally had the permissions set up for the account that I wanted to use for the application:

image

Scrolling up a bit however, I notice a bunch of permissions just for all the membership stuff. 

image

Ah, all I’m using right now is basic reads from the membership stuff, so just gave the account the above permissions and we are in business!

Hope this helps someone else along the way!

Friday, May 21, 2010 12:52:27 PM UTC  #    Comments [0] -
.NET | SQL Server | Visual Studio
# Tuesday, May 04, 2010

In this post, we are going to demonstrate some simple Ajax updates.  We will be using the AdentureWorks db for this.  You can download it here if you don’t have it.

Launch VS2010 and create a new ASP.NET MVC 2 Application:

image

For this, we’ll skip creating the test project.

Next we’ll use LINQ to SQL to generate some data models.  Right click on the Models node and Add Item (or Ctrl-Shift-A when the node is selected):

image

When the designer comes up, add the Product and ProductCategory tables.

image

In HomeController.cs create a new method called ProductSearch:

We’ll need to use our model, so add

using AWAjaxDemo.Models;

then we’ll add our new method:

public ActionResult ProductSearch(string query)
{
    IList<Product> products = new List<Product>();
    AWModelsDataContext db = new AWModelsDataContext();

    if (!string.IsNullOrWhiteSpace(query))
    {
        products = db.Products.Where(p => p.Name.StartsWith(query)).OrderBy(p => p.Name).ToList();
    }
    else
        products = db.Products.OrderBy(p => p.Name).ToList();

    if (Request.IsAjaxRequest())
        return View("ProductSearchResults", products);
    else

        return View(products);
}

 

We check to see if we have a query value coming in, if we do, we limit our query to names that start with the query. If not, we return them all.  Also note, that we check to see if this is an Ajax call. If someone has javascript off, we still want this to be functional.

Compile the project so we’ll have the model types available to us when we create our partial view.

Right click on Views/Home and add a View.  We’ll call this ProductSearchResults:

image

We’ll simplify the view down a bit to just include a few fields.  Of course, ideally we’d use a view-model for this to limit what data is even available, but that’s not the point of this post.

<%@ Control Language="C#" 
Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<AWAjaxDemo.Models.Product>>" %>

    <table>
        <tr>
            <th>
                Name
            </th>
            <th>
                ProductNumber
            </th>
            <th>
                Color
            </th>
            <th>
                StandardCost
            </th>
            <th>
                ListPrice
            </th>
           
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>          
            <td>
                <%: item.Name %>
            </td>
            <td>
                <%: item.ProductNumber %>
            </td>
            <td>
                <%: item.Color %>
            </td>
            <td>
                <%: String.Format("{0:F}", item.StandardCost) %>
            </td>
            <td>
                <%: String.Format("{0:F}", item.ListPrice) %>
            </td>
           
        </tr>
    
    <% } %>

    </table>



So, now we have a simplified partial view.

Now we’ll add our main view.  Right-click on the View/Home node and add a strongly typed empty view.  Base it on the AWAjaxDemo.Models.Product type that we did for the partial view.

image

Replace the default code with this:

<%@Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<IEnumerable<AWAjaxDemo.Models.Product>>"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  
Product Search
</asp:Content>
<
asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <
script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <
script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <
h2>
      
ProductSearch</h2>
  
<% using(Ajax.BeginForm("ProductSearch", new AjaxOptions { UpdateTargetId = "results"}))
       { %>
    Search: <%=Html.TextBox("query")%> <input type="submit" value="Go" />
    <
div id="results">
  
<% Html.RenderPartial("ProductSearchResults", Model); %>
    </div>
  
<%} %>
</asp:Content>

You’ll notice that the two Ajax scripts are referenced.  They are added to mvc 2 applications by default.  The other thing to notice is how the form is constructed.  Normally the Html.BeginForm extension method is used. Here we are using the Ajax.Begin form method and passing it a new instance of AjaxOptions specifying the target to be updated. In our case, the target is the div with the id result.  Our ProductSearchResults partial view will be rendered there after the Ajax call.

That was pretty easy … of course in a production environment, you’d want to be using caching to reduce the database calls.

Technorati Tags: ,
Tuesday, May 04, 2010 1:56:30 AM UTC  #    Comments [0] -
mvc | Visual Studio
# Monday, May 03, 2010

So I installed Visual SVN the other day on the recommendation of my good friend Paul Mehner and the setup was amazingly simple and with the client ($49 USD), the integration with VS2010 is great!

image

Get nice color coded icons showing the state of the files.

And it’s own toolbar.

image

Technorati Tags:
Monday, May 03, 2010 5:32:56 PM UTC  #    Comments [0] -
Visual Studio
# Sunday, April 11, 2010

Well, VS 2010 launches tomorrow, and I’m really excited to get my hands on the final bits.  I’ve really enjoyed working with the beta and the RC.  MSDN is down for maintenance until tomorrow morning, probably beefing up the infrastructure to handle the influx of requests that will undoubtedly be coming tomorrow.

There are some wonderful wallpapers to be had here. I set mine to #3.

Technorati Tags: ,
Sunday, April 11, 2010 4:00:18 PM UTC  #    Comments [0] -
.NET | Visual Studio
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
George Handlin
Sign In
Statistics
Total Posts: 51
This Year: 0
This Month: 0
This Week: 0
Comments: 9
All Content © 2012, George Handlin
DasBlog theme 'Business' created by Christoph De Baene (delarou)