Thursday, 29 April 2010

Friday, 19 June 2009

.net MVC yay..

.Net MVC has the possibility to change the landscape for web development.

For a while now web based Netters have been locked into this slightly unreal world where they can mostly pretend they are developing winforms: the markup has been horrible but it has been easy to deploy powerful applications quickly but often with a lumbering UI, reliant on server side for validation and intutive form operations. AJAX and the script manager did change how pages felt but still it is a long way from the semantic HTML that Google and the WAI like.

MVC has been kicking around in FLEX and Java for a while Pure and Swing being pretty popular
respectively, but beyond offering semantics to delver cleaner HTML how will it fit into .net land. Patterns like MVC represent a way of doing things, like N-tier, like spaghetti coding so basically divorcing the view from the controller means No postback, it forces you to re-think how you build an application, so at last being a web developer might mean you actually feel positive and in control when using markup .

Its a generalization but small websites that don't do much usually belong in PHP land (like facebook erm) but ASP.net websites often are used as a facade for great big business applications and it will be interesting to see if someone tries to conceptually glue MVCs to tiered apps in the near future.

PureMVC
Jeff Putz on Asp.Net MVC



Tuesday, 9 June 2009

bits and bobs

bee on a flower taken yesterday, just to brighten up an otherwise dull .net blog, until i start blogging flash bits anyways...

bee

ObjectDataSource: change insert params in codebehind

I have had mixed feelings about the objectdatasource since it popped up with .net 2.0, true it is disconcertingly easy to put in simple CRUD operations, and allows you to use generics/objects using reflection without having to muck around with datasets,

but

the process has seemed completely 'sealed' beacuase the ODS is reflected using statics to in page objects, if you try and manipulate an objects properties from code behind you hit problems immediately and yet ODS is 95% of a good solution, but adding custom JIT values to an insert was lloking like quite a lot of code.

I have found you can access the object in a create in code-behind without having to recreate the object by instancing the inner object in the dictionary on inserting.

so this in the codebehind

C#

protected void Review_ItemInserting(Object sender, ObjectDataSourceMethodEventArgs e)
{


foreach (DictionaryEntry keyEntry in e.InputParameters)
{

Review review = (Review)keyEntry.Value;
review.EmployeeID = this.Employeeid.Value;
review.LocationID = parseDD(this.gvLocations.SelectedDataKey.Value.ToString());
review.FirstName = this.FirstName.Value;
review.Surname = this.Surname.Value;

}
}



this in the front

<asp:ObjectDataSource ID="Review" runat="server" TypeName="LocationRelay" DataObjectTypeName="Review" DeleteMethod="DeleteReview" InsertMethod="CreateReview" SelectMethod="GetReviewByID" UpdateMethod="UpdateReview" OnInserting="Review_ItemInserting">
<SelectParameters>
<asp:ControlParameter ControlID="DetailTabContainer$ReviewsTabPanel$ReviewsGridView" DefaultValue="0" Name="LocationReviewID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="LocationID" Type="Int32" DefaultValue="0"/>
<asp:Parameter Name="EmployeeID" Type="Int32" DefaultValue="0"/>
<asp:Parameter DefaultValue="0" Name="FirstName" Type="String" />
<asp:Parameter DefaultValue="0" Name="Surname" Type="String" />
</InsertParameters>

</asp:ObjectDataSource>


and this in your bll


[DataObjectMethodAttribute(DataObjectMethodType.Insert, true)]
public static Int32 CreateReview(Review review)
{
Int32 intout;
intout = LocationData.CreateReview(review);
return intout;
}

don't know if this has been posted by anyone else, but i haven't found it yet, everyone is probably using linq now anyways.