asp.net-mvc

ASP.NET MVC How to get Custom Validators to work with Client Side Validation

The following validation works fine on both client side and server side <DisplayName("website")> _ <StringLength(256, ErrorMessage:="Web Address cannot exceed 256 characters.")> _ <RegularExpression("^http(s?)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", ErrorMessage:="Not a valid website address")> _ Public Property Web...

ASP.NET MVC VirtualPathProvider not working under IIS 6

By ASP.NET MVC plugin architecture, http://stackoverflow.com/questions/340183/plug-in-architecture-for-asp-net-mvc I have separated DLL(plugin) which contains the views, css and javascript files in the resources. So my own VirtualPathProvider will load the content out from the DLL if that is for the plugin. It works all fine during deve...

How would you refactor this Asp.net MVC 2 Html Helper?

Hi All, Quick question. How would you refactor this Asp.net MVC 2 HtmlHelper? Specifically would it make sense to use the TagBuilder class in this scenario? public static MvcHtmlString BusinessDisplayContacts(this HtmlHelper helper, string phone, string cellPhone, string fax, string website, string email, bool hide...

ASP.NET MVC - How controls retain their state

There are some text boxes on my page. When I submit the page, the controls retain their state after postback. I know that ASP.NET MVC does not have a concept of viewstate. So how can it be possible? ...

Moq Exception: Verifying a method call that takes parameters

I want to test that the "Create" method on the _eventManager in my controller gets called. When I run my test, I get the following exception: Test method Baigent.TheDoNation.Application.Tests.EventControllerTest.Create_Post_IfModelIsValidRedirectToSuccessfullyCreatedViewOccurs threw exception: System.ArgumentException: Invalid setup on...

In MVC Edit Action {HTTP POST} Using UpdateModel vs Request.Form Collection

I am working through sample MVC Nerdinner tutorial and using it on the AdventureWorks database. I have created an Edit action in the CategoryController to edit Product Category in AdventureWorks. The only updateable field in this table is the Name (the other fields - ID, RowGUID and UpdateDate are autogenerated). So my edit form View has...

JavaScript url auto-resolution in Asp.Net MVC

I am running Asp.Net MVC 2.0, and I am running into a problem with my JS calls. this is what I have in my : <link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="../../Scripts/jquery.js"></script> Which all works fine if I am on the root level. But if I jump up to something like:...

Error handling in asp.net mvc url

How to handle links with quotes? For example, http://samplesite.com/Users/" I want to redirect user to error page, but I see the page with exception. In every link of the form "http://somesite.com/SomeController/SomeAction/" " (double quotes at the beginning of path) Text of exception: Server Error in '/' Application. Illegal characte...

How TinyMCE is supposed to work on ASP.NET MVC page?

Hello, In a previous question someone point out to me that TinyMCE is a nice and free WYSIWYG editor. Since then, the easiest part has been downloading the resource and have a editor being displayed on an ASP.NET MVC sample page. However, I haven't yet been able to make it work (even after surfing in the net - even in the TinyMCE's we...

How to submit an ASP.NET MVC form using javascript and still validate on client side?

I have an ASP.NET MVC 2 form that is working perfectly, doing client side validation (using Data Annotations). Whenever users click on the submit button, client side validation kicks in before the form is actually posted back to the server. This is the actual code, really basic stuff: <% Html.EnableClientValidation(); %> <% using (Html...

Where to put logging in an MVC application

It should be a straight forward and simple answer, but I'm trying to figure out where to put the logging into my MVC application. Is it wise to put it in the Controller or the Model? ...

How to pass ModelErrors along with redirect?

ASP.NET MVC 2.0 I'm doing Post-Redirect-Get, if I get errors on post, I need to include ModelErrors along for the ride to along -Redirect-Get route. I send it through 'TempData': TempData["modelErors"] = ModelState. Where(item => item.Value.Errors.Count > 0). ToDictionary( item => item.Key, ...

Html.BeginForm in partial for a different controller

I have the following code: <% using (Html.BeginForm("AddComment", "Comments", FormMethod.Post)) { %> <div id="New_Comment"> <textarea name="newComment" id="newComment">Add comments</textarea> <input type="submit" value="Add" /> <div><span class="text_grey">Attach:</span><a href="#" class="link_text_grey">File</a> <a href="#" class="link...

Is MVC .net right for my project type?

After countless hours researching (creating a few demo projects, viewing webinars etc..) I feel like MVC .net works great for 90% of the web application types out there, but not for mine. Basically I have a dashboard application where I'm displaying large amounts of information in many different graphs / charts (all on the same screen)...

Repository With OrderBy

I'm trying to make a repository class that has a method to order the results based upon a "sort" parameter. I need to pass it as a parameter since I'm trying to be very strict that my repository doesn't return IQueryable and only returns List. The problem is that I have no idea how to make it so that it meets the following requirements: ...

In ASP.MVC, how to place JavaScript-friendly Stack trace of exceptions in ViewData?

When any exception occurs on the ASP.MVC server side code, I would like to take the entire stack trace of the exception and place in the ViewData and returns to the client. For example: try { //some code } catch (SomeException e) { ViewData["exceptionStack"] = e.StackTrace; } The JavaScript on the client side would ju...

request.files adds the path on localhost

Hi All, I'm using Request.Files to obtain a file that the user is uploading on my web page. I noticed that if I use the filename property in IIS it gives me a path + filename, however if I run in cassini it only gives me the filename no matter what directory I use. Why is this? And, is there a way to just use the filename when in IIS?...

Why am I getting "The directive 'control' is unknown" error in ASP.NET MVC?

Hey SO, I'm working on an editor page for a project in ASP.NET MVC. I would like to use a control for both the create page and the edit page so I don't have to duplicate code. I've set up an EditorTemplates folder inside /Views/Shared to hold my templates. And I've placed a .ascx file in there called ArticlePresentation.ascx. ArticlePr...

Deploying ASP.NET MVC2 app Issue

I'm trying to deploy my new ASP.NET MVC 2.0 website to our Windows Server 2008 box and having some issues. I created a new website in IIS, made sure the application pool was set to Integrated. When I browse to the website I get the following error. Server Error in '/' Application. Configuration Error Description: An error occurred d...

how does using HtmlHelper.BeginForm() work?

Ok so I want to know how <% using (Html.BeginForm()) { %> <input type="text" name="id"/> <% } %> produce <form> <input type="text" name="id"/> </form> namely how does it add the </form> at the end? I looked in codeplex and didn't find it in the htmlhelper. There is a EndForm method, but how does the above know to call it? The...