Category Archives: MVC3

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

This is a classic unhelpful error and nightmare. Anyway, when publishing a mvc 3 application you do not have all the requored mvc3 files on the server that is hosting your site.

The best advice I got and what actually solved the problem can be found here.

http://www.britishdeveloper.co.uk/2011/05/mvc3-deploy-could-not-load-file-or.html

Hope it helps!

 

UPDATE:

Ok, so none of the “copy local” worked for me. What did was using the deployment package that is build through my Visual Studio Solution and deploying to IIS. finally worked.

Advertisements

Some tips for using Telerik MVC Controls

I have been using the controls suite now in 2 projects and over 6 months (and the full aspnet controls for more than 3 years.). These are some important things I heave learned that makes my life a lot easier when coding with the controls.

1. Follow the telerik examples online….word for word, untill you completely understand what is being done. This is especially true in master detail tables, and or in ajax grids from the control suite. The ajax errors are really a pain to identify as it just says “Did not return JSON“. This is almost ALWAYS because you don’t have to correct scripts loaded for client side ajax processing in the grid or you didn’t follow the example online, and then waste hours solving a small mistake.

2.  If you are using EF (entity framework) for you data domain modelling infrastructure (data access), then once you have scaffolded your repositories and views, if you want ajax grids, create your own viewmodels. This will save you alot of trouble. This is because EF objects are not automatically serializable into a JSON request. You have to either build a helper class to do it, or as i suggest, create your own view models.

3. Be part of the community. Don’t be a hater. Some members of your team may approach the project with a negative attitude and yes, then they do take long completing simple tasks like a crud screen, that is their fault not Telerik. Telerik can’t be blamed for a developers incompetence and lack of willingness to learn.

There are a few more tips, however they are more technical and I will soon post them. Just thought I’d get you started and committed to using the great controls that Telerik has to offer.

 

 

JQuery Accordion in Razor View MVC3

Recently I needed to create a list of items that the user can rank eg. one above another. I used the accordion available from jquery and created one in a list, draggable and droppable, for each item in my databse that needs ranking.

At first it was a little tricky, however got it working in the end. Also included; on the drop event I post via Jquery to the databse so that the new ranking position of the item can be persisted should the user exit the form.

JAVASCRIPT

$(document).ready(function () {
var stop = false;
$(“#accordion h3”).click(function (event) {
if (stop) {
event.stopImmediatePropagation();
event.preventDefault();
stop = false;
}
});
$(“#accordion”)
.accordion({
header: “h3”,
active: false,
autoHeight: false,
collapsible: true,
encode: false,
change: function (event, ui) {

}
})
.sortable({
axis: “y”,
handle: “h3”,
receive: function (event, ui) {
$(ui.item).removeClass();
$(ui.item).removeAttr(“style”);
alert(‘receive’);
},
stop: function (event, ui) {
var currentHeaderID = ui.item.find(“a”).attr(“id”);

$.post(‘@Url.Action(“ACTIONNAME”, “CONTROLLERNAME”)’, { inCriteriaID: currentHeaderID, inRankingOrder: ui.item.index()}, function (data) {
// get the result and do some magic with it
var message = data.Message;
$(“#resultMessage”).html(message);
});

stop = true;
}
}
);
});

ACCORDION (scuzzy for the formatting, rl bsy on sumthn else act)

<div id=”accordion”>     @foreach (var item in Model)             {         <div>             <h3>                 <a id=@item.YOURID.ToString()   href=”#”>@Html.Raw(@item.YOURTITLE)                 </a>             </h3>             <div>                @* add table with more info here if you want*@             </div>         </div>             } </div>

 

%d bloggers like this: