asp.net-mvc

Getting jquery going: 'Object Expected' error

I'm creating a basic ASP.NET MVC app. I want to use jquery to have two buttons submit the form in different ways. The error I get is "Object expected". Here are the buttons: <input type="button" id="StartTask" value="Start" onclick="StartTask()" /> <input type="button" id="StopTask" value="Stop" onclick="StopTask()" /> Here are ...

Persisting Properties in Models in ASP.NET MVC (with Binder?)

Given the following code: Models class Log { ... Ticket Ticket { get; set; } string Message { get; set; } } class Ticket { ... Importance Importance { get; set; } string Name { get; set; } ... } View <%@ Language="C#" Inherits="System.Web.Mvc.ViewPage<Models.Log>" %> ... <%= Html.DisplayFor(l => l.Ticket.Name) %...

Jquery Form to insert into a table and on submit of the main form submit the table to ASP.NET MVC Controller

this may sound kind of convoluted but basically i want to have a form within a form that submits items to the parent form in a table or something of the sort and then submit that with the parent form to an asp.net controller so i can move it to the database. Anyone know of a way of doing this? I know I can inject into a table using jqu...

How to send a file to the brower using ASP.NET MVC controller action?

I have an application where I allow my users to upload a file of any type. I save this in the file system on the server. The applciation will only be accessed by two users , so I don't need to worry about uploading any dodgy files. How do I allow my user to press a button on an MVC form to request the file be sent back via the browser...

How to route legacy type urls in ASP.NET MVC

Due to factors outside my control, I need to handle urls like this: http://www.bob.com/dosomething.asp?val=42 I would like to route them to a specific controller/action with the val already parsed and bound (i.e. an argument to the action). Ideally my action would look like this: ActionResult BackwardCompatibleAction(int val) I f...

Why does ContentResult controller in ASP.NET MVC return UTF-16 when UTF-8 specified?

I have an ActionResult that returns XML for an embedded device. The relevant code is: return Content(someString, "text/xml", Encoding.UTF8); Even though UTF-8 is specified, the resulting XML is: <?xml version="1.0" encoding="utf-16"?> The ASP.NET MVC is compiled as AnyCPU and runs on a Windows 2008 server. Why is it not returni...

Embed video on a asp.net-mvc website

I will be embedding a video to my asp.net mvc website. A video on the homepage which will help people to better understand the website. I have never done this. Can anyone tell me whats the best way of doing it. Flash or silverlight?? ...

How do I obtain a list of all of the pages within an asp.net mvc project

How do I obtain a list of all of the pages within an asp.net mvc project for use in a dropdown list. I'd also like to obtain a list of all of the controls within that page. The problem is that I'd be calling this from a different project in the same solution. Can i use reflection for this???? ...

Starting a Process as a Different User in ASP.NET

I have an ASP.NET MVC web app and in one of the controller actions I want to start process (exe file). The process needs to run under a domain user, because it accesses other resources on the domain. This can either be a single hard coded user, or the user that is currently on the web page. The web.config is using Windows authentication....

How much resposibility should my repository/service have?

Hey! I have the following objects: Person <- Contact -> ClientsPerson <- Client I'm using the repository pattern with a service layer. But already here, being a perfectionist, I'm lost! I also have a PersonService, ClientService and I'm pretty sure I need to have a ContactService which should call the personService.Add(person) and cl...

How to add an attribute to an HTML tag depending on the URL in a MVC app

I render a list of items like: <ul> <li>Something 1</li> <li>Something 2</li> <li>Something 3</li> <li>Something 4</li> <li>Something 5</li> </ul> Depending on the route I want to add a class to one of the <li> tags so that I can highlight. Maybe something like: <ul> <% if (this.Context.Request.RawUrl.Contains(something1Va...

Using Code-Behind with ASP.NET MVC Views

Is it considered a bad practice to use code-behind with ASP.NET MVC Views? Got into a bit of a debate about this with my colleagues today and I was wondering the community's thoughts. Obviously, this isn't an option when using another MVC like Rails, which makes me think it's relied on more as a crutch for those accustom to working wit...

ASP.NET MVC: How to execute Data Annotation validations in the service layer?

In a recent question posed here: http://stackoverflow.com/questions/1558457/asp-net-mvc-is-data-annotation-validation-enough ...it was concluded that relying on data annotation validation (triggered by the model binder) was not enough to ensure that validation was always executed. We still need to add the same validation logic in the s...

Sorting with MVCContrib

Does anyone know how to sort the MVCContrib grid when using a complex object. My grid is displaying a list of Person and I'm trying to sort on the Country property. The problem is that Country is a property an Address class which is a property of Person. Person.Address.Country <%Html.Grid(Model).Columns(column => { colum...

ASP.NET MVC exception handling

Is it OK to catch my exceptions in the controller's actions? Is there any better way of doing it? I'm actually catching my exceptions in the controller and using TempData to show a message to the user, but I have a weird feeling about this approach. I've been browsing around but I haven't found anything that suits me. ...

How to access fields in View with different type ASP.NET MVC

Given the following code Action methods // Action for A public ActionResult New(Ticket t, int knownLocation, string location) { ... } // Action for B public ActionResult Edit(Log log, int id, string assignTo, int knownLocation, string location) { ... } Views // Ticket.ascx <%= Html.EditorFor(t => t.KnownLocation); // A <%@ Inherit...

What is the Best Way to Debug a Windows Service program in Visual Studio 2008

I am using the Microsoft Log Parser in a Windows Service. The program works in a regular web page but when I put the code in a windows service it does not work. I put Breakponts in the windows service but when I run the code the program does not stop at the breakpoint. So through out my troubleshooting I have narrowed the problem down t...

EnableClientValidation on Master Page

I'm trying out ASP.NET MVC 2 Preview and when I use client side validation it all works if the following: <% Html.EnableClientValidation() %> Is used on a content page. If it is on a Master Page - client side validation fails. Is it just me or is this by design? If so - why? ...

ValidateInput(false) doesn't seem to work when running under IIS

When I run my ASPNet MVC 2 Preview 1 website under VS dev server, it works just fine when I do a form post with Form Method "Get" - the form has a textbox with text that has angle brackets (for ex: "i < 10;") However under IIS, when the same form is posted (using Method "Get"), I get a 404 page not found. The resource cannot be found. ...

Books that will cover TDD, DDD and Design Patterns in .NET

I would like to get book(s) that will really give me a complete view of modern ASP.NET development using C#, TDD, ASP.NET MVC, DDD and Design Patterns such as the Repository pattern. I'm very competent with C# and ASP.NET MVC, but want to fill in the gaps. If you've had a good experience with a book or two that covers these topics coul...