asp.net-mvc

ASP.NET MVC 2 Preview 2 - Extend LabelExtensions.LabelFor

I'm wondering if anyone has attempted to write an extension helper to the LabelExtensions.LabelFor HtmlHelper in MVC2? This would be useful for me in that my app requires that I always wrap labels in a <td> tag with a class attribute. Rather than have that code repeated in the View I thought I could write a little extension method: publ...

How can I change the mvc ajax form parameters in the posted-to controller?

For example, if I wanted to change the UpdateTarget or the InsertionMode in the controller after the form was posted. ...

ASP.NET MVC - Build Search Results into a Div

I'm new to ASP.NET MVC, but I need to perform a search for articles that match a selected category. The results of this query need to be written into a "search results" div overlay with DHTML- jquery, probably. So, I need the results of an Action, but not to render a view. I was thinking I could use Json and then iterate over the res...

How can I generate this XML page dynamically in C# / ASP.NET MVC?

I'm trying to create an XML file to conform to Indeed.com's Job Listing XML. It looks like: <?xml version="1.0" encoding="utf-8"?> <source> <publisher>Super X Job Site</publisher> <publisherurl>http://www.superxjobsite.com&lt;/publisherurl&gt; <job> <title><![CDATA[Sales Executive]]></title> <date><...

The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

I have an ASP.NET MVC application where I am editing an existing database to update a paticular field, DateTime. My database has 4 fields, two of which are DateCreated and DateModified. When I try to update the field, I want to keep DateCreated time the same, no reason to update the date it was created, and I change the DateModified time...

Why ASP.NET MVC 2 will have its own client-side validation?

I am interested what are possible reasons that ASP.NET MVC 2 will have its own client-side validation instead of merging with xVal validation framework? Has someone from ASP.NET MVC team blogged about it? ...

How can I test an event of a MVC controller

I want to test the OnException, OnActionExecuted event of an MVC controller. If I use mock like this: var httpContext = MockRepository.GenerateMock<HttpContextBase>(); var request = MockRepository.GenerateMock<HttpRequestBase>(); httpContext.Expect(c => c.Request).Return(request).Repeat.AtLeastOnce(); r...

ModelBinder not bind the values

Hi I have an action in my controller, i am waiting to ModelBinder bind the incoming postdata to my action parameter but it doesnt do this, i dont know. I only manually bind them with TryUpdateModel() but i dont want to use it. Property names and the postdata are the same why it cant bind them ? public class User { public string Fir...

Translation with resource files, Internationalization asp.net

i have an asp.net mvc application, and i use data annotations for data validations something like this: public class Booking { [Required(ErrorMessage = "Please enter your name")] public string Name { get; set; } ... so this is in my DomainModel and i need to translate the ErrorMessage, and to use the translation in my v...

ASP.NET MVC user friendly 401 error

Hello. I have implemented errors handling in ASP.NET MVC site in a way like suggests this post: http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc/620559#620559. With 404 errors all works fine. But how correctly show user friendly screen for 401 error? They usually do not throw Exception that can be ...

How to solve duplicate objects in dynamic loading page by using jQuery?

I want to solve duplicate objects in dynamic loading content. Please look at the following source code for easier understand. Base Page HTML With 1 Dynamic Loading Content <body> <div id="general-div"></div>> <div id="div1"></div> <div id="placeholder1"> Dynamic Content will be placed inside this. <...

IIS7 and clientCaching with ASP.Net MVC

Hi, Is it possible to declaratively set clientCaching for an Action using the web.config in IIS7. We need to set an expiry value of 1 day for our Home/Index Action. As of now we are doing this using a filter attribute. Is it possible to accomplish the same declaratively? We are able to do it for static content, but not for Action Method...

ASP.net MVC Localization | why do it the difficult way?

Main question: Why use custom localization helpers if there is something built-in doing the same already? Long story Currently I have been reading many options to localize your asp.net mvc website. Most of the posts are old, from oktober 22 2008 for instance. I think one of the most linked option is the following: Matt Hawley on eW...

creating a create/edit view/action with SelectList in asp.net mvc

the basic idea is that you have some class that has a reference type property, something like this public class Person { public int Id { get; set; } public string Name { get; set; } public Country HomeCountry { get; set; } } public class Country { public int Id { get; set; } public string Name { get; set; } } now if ...

Update only the changed values on Entity object

Hi, how can i automatically update my entity objects changed values and save them to db. I hava an Action like that public ActionResult Update() { User userToUpdate = new User(); TryUpdateModel<User>(userToUpdate,ValueProvider); BaseRepository.Context.AttachTo("User",userToUpdate); BaseRepository.Context.Sa...

Detecting redirect in IActionFilter.OnActionExecuted reliably

I have an IActionFilter that does something in OnActionExecuted, however I don't want to perform this action when the controller result performs a redirect. My initial thought was to check the type of the ActionResult as either RedirectResult or RedirectToRouteResult, but this isn't reliable as any type of result can perform a redirect ...

ASP.NET MVC - Authorization Refactor

The problem i see with this code, is that it's going to be reused a lot; anything being edited/created by a authenticated user (except for Site administrators) will only have access to a their "studios" objects. My question to you all; how would you re-factor this so the service layer can be abstracted away from the knowledge of the cl...

ASP.net MVC - How to persist model over various views.

Situation: In some project management software written in asp.net I have a create project page (working fine). I need to add to this the ability to add tasks from a list of templates to this project pre-creation BUT the list of available tasks is dependent on some values sitting in the create form. My abstract solution is this: I h...

What are the good practices for hosting MS Windows Workflow runtime for an asp.net mvc application?

Hello Gurus, I'm working on a asp.net mvc project that will use MS Windows Workflow Foundation to manage client business work flows. These are long running workflows spanning in time over a year or two. So we've decided to use State Machine workflows. A workflow instance will be persisted to a database when not being used (or in idle...

image shows only when debugging

Hey All, I have a partial view that contains an img like so: <img src="" alt="test" id="chartImage" style="display: none;" /> And then in my view that contains it my javascript looks like this: if ($(this).val() != '') { setTimeout(function() { $('#chartImage').attr("style", "") ...