asp.net-mvc

ASP.NET MVC Modify CSS links via code (runtime/development)?

Hi there, does anyone know of a good way of doing the following, I need to have available via CSS Links up to 5 CSS files in one, this is pretty bad for trips to the server.. but it helps me keep it organized... At runtime i automatically consolidate and minify all css files into 1 ... What i was wondering is how to have links to css ...

ASP.NET MVC Create view for object with first child object

I have a 'Person' object that has a 'FirstName' and 'LastName' property. The 'Person' also has a 1-n relation with a 'Phone' object. The 'Phone' object has a 'Number' property. So a person can have multiple phone numbers. On the 'PersonController' I have a 'Create' action that loads a strongly-typed view to show a form where I can creat...

Installing a modified version of ASP.NET MVC

I have made a relatively simple change to the MVC 1.0 source code to correct a bug in the DropDownList HtmlHelper (discussed in another question). I was able to rebuild the MVC solution, ran all the tests, including the one I hadd added to show the bug I was fixing, and built a new DLL. But how do I use that? I tried moving the new MV...

Way to avoid FormCollection for ASP.NET MVC?

I'm very noob when it comes to ASP.NET MVC. I'm looking at the starter example from the ASP.NET MVC add-in. I see something like this was automatically generated: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here return RedirectToAct...

How to control ASP.NET MVC Route generation?

I have a route like routes.MapRoute( "Reports", // Route name. "reports/{controller}/{action}/{id}/{start}/{end}", // URL with parameters. new { controller = "Home", action = "Index", id = "", start="", end="" } // Parameter defaults. ); where start ...

ASP.NET MVC: When to set Thread.CurrentThread.CurrentUICulture?

I am just beginning to localize an ASP.Net MVC application. Most of the strings will be defined in resource files and retrieved via Matt's Localization Helpers. Other strings must be stored in a database. My Question: Should I set CurrentUICulture early in the request pipeline and use that throughout the application, or directly use ...

Accessing URL parameters on MVC framework

public ActionResult Edit(string param) { } http://localhost/Edit/5,someothervalue,etc How can i reach 'param' from a global function. Basically I am trying to access the parameter in my url from a statinc method that I am building which will be global. That method breaks down the parameter and returns id and other things that I am pa...

SecurityException: Request for the permission of type AspNetHostingPermission failed

Setting up a new developing workstation, when I run the ASP.NET (MVC) application from Visual Studio 2008 I get a SecurityException. Any ideas what might be the problem? I am accessing the data files over SMB (it's a shared mounted as Z:) and I've given full trust to it by running caspol -m -ag 1 -url “\\server\share\” FullTrust -exclu...

Html.DropDownList - Disabled/Readonly

Hi, What option do I need to set to make a drop down box readonly when using MVCs Html.DropDownList? I've tried things like.... Html.DropDownList("Types", Model.Types, new { _Enabled = "false" }) ...and many different things along this line; alas no joy! I thought this would be an easy.....and it probably is!!!!! Thanks, ETFairfa...

How to put css in MVC projects (vb!)

Hi! Sorry my very poor english… I'm migrating web form project to mvc and i have a lot of doubts. One of them is how to put css on mvc controls like textbox for example. How do that in visual basic? i only saw c# implementation and it seems working, but on vb don't: ex: <%= Html.TextBox("txtDate", Nothing, New { @class = "csstext" })...

How can I make a generic IQueryable in Linq?

Hi everyone!! I'm working in a ASP.NET MVC project and I have this particular situation: I have 3 pages - Product, Order, User. And in each of these pages I have a link calling the same ActionResult differing only by the argument passed depending on the page I'm in. For example: public ActionResult(string typeOfPage) { if (typeOfPag...

Having trouble with Dependency Injection and ASP.NET MVC

Hi folks, I've got a greedy constructor defined for my Controllers. Each controller requires an ILoggingService instance. Now my dependency injection (which is StructureMap .. but if you don't use that, please keep reading) works fine .. but I wish to make it that the ILoggingService greedy constructor requires a String. This value will...

Where should a ViewModel sit in the directory structure of an ASP.NET MVC application

I am about to create a ViewModel to pass some data to a View. So if the application structure is convention based. Where are the ViewModel definitions to be kept. I could create a new directory called ViewModels, but what is the RIGHT way. ...

Validation of Business Logic in Asp.net MVC Using Exceptions

Hi all, I have a question regarding the method i am using for doing Business Rule Validations in asp.net mvc. Currently i have an exception class that looks something like this public class ValidationException : Exception { private ModelStateDictionary State { get; set; } public ValidationException(ModelStateDictionary state)...

Can AntiForgeryToken be used in a Javascript Post?

if so can show simple example, ex in jquery ajax.post ...

ASP.NET MVC: Clear an action's cache from another action

Is it possible to clear one action's cache from another action? Let's say my Index action lists all my Widgets. There are lots of Widgets but new ones are not created very often. So I want to cache my Index action indefinitely but force it to render after a successful Create. public class WidgetController : Controller { [OutputCach...

ASP.NET: Webforms and MVC pattern

Hey I have developed a webapplication in both ASP.NET MVC and ASP.NET Webforms and i'm wondering isn't Webforms following the rules of the MVC Pattern just the as ASP.NET MVC is? I mean we have the .aspx file which holds the visual (HTML and JavaScript) and then the code behind file which controls the user interaction and data for the ...

MVC Pattern: What other Pattern to use with it?

Hey I have developed a MVC web application with ASP.NET MVC and im just wondering which Pattern you prefer to use with a MVC project? ...

[ASP.NET MVC] How to get all action names from a controller

How could I write code to get all the action names from a controller in asp.net MVC? I want to automatically list all the action names from a controller. Does anyone know how to do this? Many thanks. ...

Use Lambda Expression within ASP.NET MVC View using VB.NET

With ASP.NET MVC 1.0, .NET 3.5 and C# you can easily pass a method a lambda expression that will do a "Response.Write" some content when it's executed within the method: <% Html.SomeExtensionMethod( () => { <% <p>Some page content<p> %> } ) %> The method signature is similar to this: public void SomeExtensionMethod(t...