asp.net-mvc

How do you handle the output of a dynamically generated form in ASP.NET MVC?

Say you create a form using ASP.NET MVC that has a dynamic number of form elements. For instance, you need a checkbox for each product, and the number of products changes day by day. How would you handle that form data being posted back to the controller? You can't set up parameters on the action method because you don't know how many ...

HttpContext on instances of Controllers are null in ASP.net MVC

This may not be the correct way to use controllers, but I did notice this problem and hadn't figured out a way to correct it. public JsonResult SomeControllerAction() { //The current method has the HttpContext just fine bool currentIsNotNull = (this.HttpContext == null); //which is false //creating a new instance of a...

ASP.NET MVC: Best way to get form checkboxes into many-to-many DB assoc table with LINQ To SQL?

Hi, I have an ASP.NET MVC view which contains checkboxes for user-defined categories. <td><% foreach (Category c in (List<Category>)ViewData["cats"]) { if (selCats.ContainsKey(c.ID)) { %> <input name="CategoryIDs" type="checkbox" value="<%=c.ID %>" checked="checked" />&nbsp;<%= c.Name%><% } else { %> <inpu...

Can I pass an anonymous type to my ASP.NET MVC view?

I've just started working with ASP.NET MVC now that it's in beta. In my code, I'm running a simple LINQ to SQL query to get a list of results and passing that to my view. This sort of thing: var ords = from o in db.Orders where o.OrderDate == DateTime.Today select o; return View(ords); However, in my View, I rea...

Where are ASP.NET MVC docs?

I am very impressed with the ASP.NET MVC stuff--and I've seen the various blogs and am quite anxious to dig in. But where are the docs? I can't find any docs on the System.Web.Mvc namespace, or any of its related namespaces. Google searches limited to msdn.microsoft.com don't turn up anything, nor does just googling. I know there are a...

Why the query strings in my ASP.NET MVC route?

On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink will return to me URLs containing querying strings. I have isolated the circumstances that produce this behavior, but I still do not understand why, instead of producing a clean URL, it decides to using a query string parameter. I know that functionally they...

Remove or change Default Route post Global.asax

I'm building a CMS in ASP.NET MVC and want to allow users to pick which page they want to be displayed by default when the user first visits the site. I set my default route in Global.asax, like so (for example): routes.MapRoute( "Default", // Route name "{co...

Using aspx Rendering Engine to Generate Non-HTML

Is it possible to use the asp templating engine (With the partial code-behind class, dynamic <% ... %> blocks and such) to generate non HTML? I want to have a clean and maintainable way to generate code dynamically. (Specifically, I want to generate LaTeX code populated with values from a database.) Currently my LaTeX templates are res...

What's the best way to copy and insert data from related tables into a new set of related tables with Linq

I work on a web game , I use asp.net mvc, linqtosql. I have 3 tables that store default game values: DefaultRegions, DefaultSubRegions and DefaultCountries. These 3 tables are related to each other thanks to primary / foreign keys. I need to copy the values of these tables into 3 tables called Regions, SubRegions and Countries when som...

How to Dynamically add menu items to master page in ASP.NET 3.5 MVC app

I want to dynamically add menuitems to my master page based on membership security login role. From what I've read RenderAction in the master page html could perhaps do this. Since I'm fumbling thru this I am not sure how it would look and how in the controller I check my current role. I am considering creating a table and relating the a...

ASP.NET MVC controller actions that return JSON or partial html

I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously? ...

ASP.MVC Beta Install Problems

Hi, I've just downloaded the ASP.MVC MSI package, but the installation fails with the "There is a problem with this Windows Installer Package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor." message. I see that other people too have the same problem (http://forums.asp.ne...

How can I unit test an MVC UserViewControl?

I've been trying for a while now to write a unit test for a UserViewControl in ASP.NET MVC. I'd like to get to code that looks something like this: [TestMethod] public void HaveControlToDisplayThings() { var listControl = new ControlUnderTest(); var viewData = new ViewDataDictionary<IList<string>>(this.repo.GetMeSomeData()); ...

ViewData.Model in partial is null

In my main page (call it index.aspx) I call <%Html.RenderPartial("_PowerSearch", ViewData.Model);%> Here the viewdata.model != null When I arrive at my partial <%=ViewData.Model%> Says viewdata.model == null What gives?! ...

RE: Using themes with ASP.Net MVC

I have an ASP.NET MVC (Beta 1) website that I'm using themes with. When I start my site (I'm still running using the ASP.Net Development Web Server) the default page gives me this error: Server Error in '/' Application. Using themed css files requires a header control on the page. (e.g. ). Description: An unhandled exception occurred...

Is BindingHelperExtensions.updatefrom / Controller.UpdateModel insecure?

I've been reading about UpdateFrom, used to update a business object from the request. Is it massively susceptible to XSS code and extra form parameters being posted? ...

Postback not working with ASP.NET Routing (Validation of viewstate MAC failed)

Hi. I'm using the ASP.NET 3.5 SP1 System.Web.Routing with classic WebForms, as described in http://chriscavanagh.wordpress.com/2008/04/25/systemwebrouting-with-webforms-sample/ All works fine, I have custom SEO urls and even the postback works. But there is a case where the postback always fails and I get a: Validation of viewstate MAC...

IModelBinder and ASP.NET MVC Beta

Does anyone have links to tutorials regarding the new IModelBinder in asp.net mvc beta? I can't get my head around it properly, so much has changed. Thanks ...

Questions on differences from ASP.NET 2.0 to ASP.NET 3.5 MVC

We are moving from regular 2.0 webforms with no testing to TDD MVC I'm looking to find out all the requirements for making the jump from 2.0 to 3.5 MVC. Does SQL Server 2000 work with .net 3.5? Does the MVC Framework come with .net 3.5? How does AJAX work with all this stuff? Is visual studios team suite worth the time/money? ...

ASP.NET MVC Beta - Grouping Controllers and Views possible?

I am on the way to build an ASP.NET MVC application with the latest beta release and I wonder if it is possible to change the default project Layout of /Views/Home/Index.aspx /Views/Home/About.aspx to /Blog/Views/Home/Index.aspx /Blog/Views/Home/About.aspx /Forum/Views/Home/Index.aspx /Forum/Views/Home/About.aspx The goal is to get ...