Is it best practice to put data validation annotations in the Model or View Model? What are the advantages/disadvantages of one approach over the other?
Curious to see where everyone is putting their validation, I am currently doing it in the model project. However I have seen a few people say this is not best practice.
...
So I have been using data annotations for my validation in an MVC project and they seem to work in most scenarios.
Here are two examples in my current project where they don't seem to fit and I am unsure of the best place to put the validation.
1) I have a Join League page that contains a form where the logged in user enters their t...
How could I cache an entire page except a bit at the top which says something along the lines of "Welcome back, Matt! | Log Out" if the user is logged in and so-on?
I'm using ASP.NET MVC 2.
...
I'm following the NerdDinner ASP.Net MVC tutorial and I have the following line of code:
<%= Html.ActionLink("Edit Dinner", "Edit", new { id = Model.DinnerID}) %> |
<%= Html.ActionLink("Delete Dinner", "Delete", new { id = Model.DinnerID }) %>
What I don't understand is why the third parameter of the ActionLink requires a new ...
Hi,
I have a three database tables related for example: company( one - one) Contact( one- one) Address,
I need to create a company, then create contact for company, then create an address for contact in one page (to make things easier for user).
the user doenst have to fill all the details at once and submit it, he may create company ...
Brief:
I have a sub classed AuthorizeAttribute in my framework in which I am doing custom authorization.
I am in the process of switching from normal asp.net mvc view rendering to Ajax rendering via jQuery. Hence every link in the application does a ajax call to get the data.
In order to cater for this I have converted most of my page...
I'm on ASP.NET MVC and I'm using Google Maps API with Javascript. I send a Model to the View with one or more waypoints to add to the route.
function calcRoute() {
initialize();
var start = "<%= Model.StartAddress %>";
var end = "<%= Model.ClientAddress %>";
var waypts = [];
waypts.push...
Hi
I am looking for any tutorial or document about how to use telerik asp.net ajax controls with asp.net mvc views
thanks
...
All examples that I can find do something like this:
[Required]
public string Title { get; set; }
That's great for simple cases, but what about something that checks the database or something else server side?
For example, say I have a movie database and I want to allow people to rate it. How could I tell if someone has already rated...
I'm creating asp.net mvc login page. This is simple. Same as others. Controller contains 2 method.
My problem is
I'm debugging First LogOn method. ReturnUrl has value. for example "Admin/Index". After debuggin Second LogOn method. But ReturnUrl is Null.
public ActionResult LogOn(string ReturnUrl) // First method
{
return View()...
I'm developing Asp.MVc 2 application. In solution i've about 10 projects and i have no idea why bulid takes so much time - ~5 minutes.
I've tried to unload some projects, but it saves mayby 15 seconds.
I'd like to try and learn TDD, but writing and running tests will waste 80% time.
I'm using VS2010 and default MSBuild - is there any ...
i have error in CANCEL button in file uploader.The CANCEL button does't work if i tried to remove(cancel) ADD MORE FILE button.
here is the javascript code:
<script type="text/javascript">
function addFileUploadBox() {
if (!document.getElementById || !document.createElement)
return false;
/*************...
I'm working on a project and I would like to be able to place a number of views within the shared folder. However when these are all created (through a generation process) i begin to feel "custer&^%$ fobic" due to having X * N partial views within the shared folder and am looking for a better organizational model.
Is it possible to ju...
This is driving us crazy... In VS2010, MVC2 projects, not all projects.... both on a project that was upgraded from 2008/mvc1 and on a brand new project created within 2010/MVC2, we have the following behavior:
1) develop as normal..
2) hit F5 or CTRL-F5 to open up a browser
3) works great!
4) add a CSS file (or JS file or any file...
Somehow I cannot get a simple map to work in a ASP.NET MVC 2 application with Google Maps Javascript API V3. I have tried the following:
Site.Master:
Removed
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Added
<!DOCTYPE html>
Added this in < head >
<script type="...
I'm handling the submit portion of a ASP.NET MVC 2 page via javascript/JQuery because i need to construct some arrays, in the controller i either return back a View (if there are errors) or a URL (redirect)
I can handle the URL fine, but i have no idea how to handle returning a View object
public ActionResult Update(List<string> items,...
Hi folks,
I replaced the ASP.NET ControllerFactory by a WindsorControllerFactory.
And I registered all controllers and interceptors. Until here everything working well.
Now when I am debuging my Interceptor I always get Execute from ControllerBase in invocation.Method.Name. I need to get the action name and the parameters of the acti...
So I have an MVC 2 app that uses the Active Directory Membership Provider. Authentication works like a charm! Now I need to add some additional screens to allow the users to:
Change their password
Reset forgotten passwords (email a super secret link or something?)
Conditionally add additional users (of course users of a certain role, a...
On the home page of my site I want to display a lot of products which have images which are quite large. Currently the page is taking so long to load that it is actually timing out and the page fails to display!
In MVC, or just ASP.NET in general, how can I load an image asynchronously? Basically what I want to do is display the detail...
I am trying to make a validator that will make sure that at least 2 items are selected. The validator works correctly on the server side but the client side code never gets executed.
Here is the code:
Sys.Mvc.ValidatorRegistry.validators["country"] = function (rule) {
var min = rule.ValidationParameters["min"];
...