Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Wednesday, June 23, 2010

While trying to figure out what is meant by the 3rd new section in a view in MVC

<%: Html.ActionLink("Edit", "Edit", new { id=item.DinnerID }) %>

So it is really creating an object with a single property id, which is an int, equal to that of the item, which is a Dinner.

image

“Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to first explicitly define a type”

class Program
{
static void Main(string[] args)
{
// Anonymous types provide a convenient way to encapsulate a set of read-only properties
// into a single object without having to first explicitly define a type
var person = new { Name = "Terry", Age = 21 };
Console.WriteLine("name is " + person.Name);
Console.WriteLine("age is " + person.Age.ToString());

// Anonymous types just get rid of Person1 really.
Person1 person1 = new Person1 { Name = "Bill", Age = 55 };
Console.WriteLine("name is " + person1.Name);
Console.WriteLine("age is " + person1.Age.ToString());
}
}

class Person1
{
public string Name { get; set; }
public int Age { get; set; }
}

Many thanks to the question here for clarifying:
 
Comments [0] | | # 
# Tuesday, June 22, 2010
( Azure )

In the 1.2 Release of the SDK we can now publish straight from VS instead of manually uploading files.

The end results is this:

image

which automatically publishes up to the cloud and runs the app making it live.

The way to do it is to select manage in Credentials, which brings up this box:

image

1. Create a self signed cert. 

2. upload it to the dev portal

3 grab your subscriptionid from Account page

You’ll need a storage account to setup through as well.

Comments [0] | | # 
# Thursday, May 27, 2010

DevDays – MVC – Scott Hanselman video:

WFT1_2MB_ch9.wmv 1.4GB

Looking at the callstack in debug to see how things are called.

image

IHttpHandler – the ‘simple’ building block of ASP.NET.

Example in c:\code\mvc2\hanselman

image

http://localhost:1476/Home/poop/2

Controller get invoked

Action invoker calls the method

Model Binding – took the other piece of the route data (ie 2) and coerced it into…

didn’t call HttpRequest or anything..

 

Passing a DateTime

image

image

Phil Haack Route Debugger

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

 

image

prop tab tab to auto gen the properties. then tab tab, then enter enter!

Create A Controller

Ctrl M, Ctrl C

Convention is HomeController

var p = new person

then ctrl period to import the namespace.

Create A View

Convention is in Views directory, create a new Person directory.

Index method links to Index view

Details method links to details view.

image

image

Ctrl M Ctrl V to create a view, when you are in the appropriate Controller class (eg Index)

Created a strongly typed view.. this Viewpage is of type Person

Model in the viewpage will always be of type T ie Person.

Could use Repository Pattern for the DB

Going live with ASP.NET4 – many hosting providers need you to upgrade to another machine.

image

Going Live on Azure

Created a new MVC2 Web Role project

Upload to test that MVC2 is working somewhat

ViewModel - MVCMusicStore

VS2010 Control comma – navigate to

http://mvcmusicstore.codeplex.com/

Uses Entity Framework.

Uses <%: HTml.DisplayForModel

AutoMapper

FirstName, LastName.. map to FirstName and Surname

image

ViewData

is another way to pass data.

image

ViewEngines

This is the WebForms view engine.

Routing

 

NerdDinner – MVC2 in beta (now it is live 27th May)

there are unit test in here.

image

just asserting not null.

Seperation of Concerns – in controller we can’t have Response.Write.. as it would break in this test.  Would work at runtime.

Comments [0] | | # 
( Azure )

Personal storage

Endpoints:

xxxxx.blob.core.windows.net

xxxx,queue.core.windows.net

xxxx.table.core.windows.net

This part of Windows Azure and not SQLAzure or AppFabric

image

azurestorageexplorer.codeplex.com

image

Also looking at Azure Diagnostics Manager from cerebrate.com

http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/e972b0c0-3a04-4f0c-a73f-ab93552d8291

Example using ASP.NET and Storage and AppFabric Local Dev

http://msdn.microsoft.com/en-us/magazine/ee336122.aspx

Logging

Each app has to do its own logging and write to storage.. an app like this can nicely show what is happening.

image

http://microsoftpdc.com/sessions/svc15 –  this is pdc09

MIX2010 – Building and Deploying Windows Asure Based Apps

http://live.visitmix.com/MIX10/Sessions/SVC09  (Jim Nakashima)

Created a WebRole and a WorkerRole

image

One of the web roles.. when I clicked on the button, the worker role picked up the message from the queue.

Nerdinner MVC1 Migrating to Azure with SQLAzure

Could use Azure tables (examples on the web)

Need to do 3 things:

- Need to make a webrole

- Migrate dinner to use SQLAzure

- Migrate asp.net membership provider for SQLAzure.

Comments [0] | | # 
( SQLServer | VMWare )

 

using the Web Plaform Installer. installation of the Studio didn’t work

tried ccleaner which didn’t work.

http://goneale.com/2009/05/24/cant-install-microsoft-sql-server-2008-management-studio-express/

Trick is to get the DB Server and tools together: **No this is just SQL Server 2008, not R2**

https://www.microsoft.com/downloads/details.aspx?familyid=7522A683-4CB2-454E-B908-E805E9BD4E28&displaylang=en

But as I’d compressed my C:\ drive on WMWare Player it came up with an unusual error.

This is good:

image

image

Expand Boot Drive on VMWare Player3

Need VMWare Player 3.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1004047

Can simply edit the drive information in the player GUI, then goto Windows7 click on C:\ drive in admin tools and management, and then do expand volume.

Comments [0] | | # 
# Wednesday, May 26, 2010
( Azure )

http://blogs.msdn.com/b/brandonwerner/archive/2009/11/28/how-to-host-your-site-and-content-on-azure-quickly-and-easily.aspx

Local Development Fabric and Development Storage (uses SQLEXPRESS)

image

Live ‘Fabric’ and Storage which consists of Blob, Queue and Table

image

SQLAzure is something else!

AppFabric is something else.

Comments [0] | | # 
# Saturday, May 22, 2010

Discussed in stackoverflow question.

TFS 2010 basic.. same cost as VSS
Perforce - google use it? USD$800 per user
SourceGear Vault and Fortress - good VSS upscale... USD$300 / $600

SVN.. free...VisualSVN Server.. SVN 1.6.6

fi.github.com - USD$600 per user.. min 10
cobebasehq - ??

The Big Picture

On ‘Joels Test’ here are some of my favourites:

1. Do you use source control?

4. Do you have a bug database?

6. Do you have an up-to-date schedule?

7. Do you have a spec?

8. Do programmers have quiet working conditions?

9. Do you use the best tools money can buy?

source control eg Git
bug tracking eg FogBugz
work items
continuous integration eg Cruise Control
collaberation
document management

Comments [0] | | # 

I’m spiking out a website that needs to have users logging into the front end so they can see their own personal information.

http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/public-users-authentication.aspx

They are using ASp.Net 2.0 Membership and Role Model.

Here is an example of using the same membership provider:

http://www.sitefinity.com/support/forums/sitefinity-3-x/bugs-issues/creating-new-user-authentication-and-authorization.aspx

 

here:

http://www.sitefinity.com/blogs/ivan/posts/08-01-07/sitefinity_social_network_platform_part_1_rudimentary_specs_and_ideas.aspx

http://www.sitefinity.com/blogs/ivan/post/08-01-17/sitefinity_social_network_platform_part_2_setting_up_public_side_membership.aspx

 

make a new project to play with

  • Home – visible in navigation
  • Groups – visible in navigation
  • Person – not visible in navigation, Page group
  • Login – not visible in navigation
  • Registration – not visible in navigation

    image

    image

    So have got registration and login working on the front end.

     

    how to display pages only to logged in users?

    image

    image

     

    Manage password

    http://www.sitefinity.com/blogs/josephanderson/posts/08-12-12/change_password_and_password_recovery_controls_in_sitefinity.aspx

    image

    just created a user control withPasswordRecovery and ChangePassword from asp.net.  Then uploaded as an ascx user control.

    **how to get the specific user, so can query against them in the database in a custom control (see contacts example).

     

  • Comments [0] | | # 
    ( Telerik )

    Whilst using Telerik’s CMS SiteFinity (see other blog posts) I started to use their RadGrid.

    So why use these third party components? According to Telerik:

    “…help you build high-quality, professional line of business web applications. …maximizing productivity and creating rich, SEO-friendly, high-performance Enterprise web applications.”

    Their Grid is USD999, and has combined questions in their forums of 100,000 on the grid (over asp.net and asp.net ajax).  It is their most popular control.

    So what can it do?  Here is an example showing LinqToSQL as the ORM

     http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/linqdatasource/defaultcs.aspx

    http://tv.telerik.com/radtips/episode/using-the-linqdatasource-in-your-radgrid

    image

    Got some issues with errors and internal server errors on my shared host. 

    <customErrors mode="off"/>

     

    Theme: Web Blue

    image

    Drop Down:  link to CountryID, a new data Source

    image

    Data Editing:   AllowAutomaticDeletes, Inserts, Updates

    Paging:  PageSize = 20

    MasterTableView, EditMode, InPlace

    image

    and can edit the country as well with a drop down.

    Date – used {0:d} to only get the date

    Cost:

    image

    image

    How to Do a Drop Down based on a filter

    Using a RadComboBox:

    Chosen the datasource, and DataText field = name  and DataValueField  = countryid

    image

    AutoPostBack = true

    Put a conditional on the original linked data source.

    image

    It all works as expected.

    Uploading to live

    Project is now:  TestRadGridTelerik3… uploading to radgrid2 on server

    Add a Record

    image

    Mastertable view, CommandItemDisplay = top

    Manually Controlling The Grid

    I want to be able to insert into the grid, based on my logged in user.  So have to manually hook into the events

    http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/programaticlinqupdates/defaultcs.aspx

    http://www.telerik.com/help/aspnet-ajax/grdlinqtosqlmanualcrudoperations.html

    Using TestRadGridTelerik3 project, addSmart.aspx

    <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="False" AllowPaging="True"
            OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand"
            OnItemCreated="RadGrid1_ItemCreated" OnDeleteCommand="RadGrid1_DeleteCommand"
            OnInsertCommand="RadGrid1_InsertCommand" GridLines="None">

    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />

    image

    Very nice goodness baked in for delete

    protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
    {
    var raceId = (Guid) ((GridDataItem) e.Item).GetDataKeyValue("RaceID");

    //retrive entity form the Db
    var race = DbContext.races.Where(n => n.raceid == raceId).FirstOrDefault();
    if (race != null)
    {
    //add the category for deletion
    DbContext.races.DeleteOnSubmit(race);
    try
    {
    //submit chanages to Db
    DbContext.SubmitChanges();
    }
    catch (Exception)
    {
    ShowErrorMessage();
    }
    }
    }

    There is a double click event on the row.. which goes into edit mode.  This is wired up in JavaScript.

    Getting nice js numeric error checking on the input for money and distance.

    image

     

    Have got delete working

    **Update doesn’t work

    **Insert doesn’t work

    **The error message don’t show up properly.

    **changed teh db structure locally for race to allow nulls for categoryid… maybe vioates an FK constraint.??  see profiler?

    Problem with Updating

    Found that I couldn’t understand what was happening.  So went back to the example code by Telerik on: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/programaticlinqupdates/defaultcs.aspx

    Ripped out the code, made a simple LinqToSQL class against 1 table only (Products).  Got it working locally:

    image

    this is called RadGrid4Telerik.

    Next step is to get my example of races working with 1 table only (just like this).  Problem with taking this live is that Northwind is quite a large db and complex and I’ve got average hosting!  Also very good to bring back to basics.

    Comments [0] | | #