asp.net-mvc-2

ASP.NET MVC2 - number and location of try/catch(throw?) blocks

I'm in the process of thrashing through the whole exception-handling jungle, and I'm now trying to determine just how many try/catch blocks I need, and where to put them. From my controller I have CreateInvitation(fromUser, toUser); which calls down to my BLL method public static Invitation CreateInvitaton(User fromUser, User toUs...

MVC View Bind with form post and display data in the same page.

Hi All, As I have started working on MVC application, I have one query for the same. I have one textbox (for employee name as I want to retrieve data basis on this) in the page , I want to post the form and get result of 'Employees' data in the same form. (I want to show grid type layout in the same form just below to the textbox) Cou...

how to create a helper that is going to render a partial view with a model ?

I'll give a very simple example: at the moment I have to write like this: <% Html.RenderPartial("hello", new HelloInput { Name = "Jimmy" } ); %> I would like to be able to like this: <%=Html.Hello("Jimmy") %> So I would like to know how create this helper: public static string Hello(this HtmlHelper helper, string name) { retu...

asp.net mvc validation problem

This doesn't make any sense to me. Look at this ViewModel: public class SelectService { [Required] public int? SelectedServiceId { get; set; } } Look at this Action: [HttpPost] public virtual ActionResult SelectService() { TryUpdateModel(WizardContainer.SelectService, "SelectService"); TryValidateModel(WizardContaine...

How do I access other attribute values from inside a custom ValidationAttribute in an asp.net mvc 2 application?

I'm using asp.net mvc 2 with C# and DataAnnotations. The situation is this: I have a custom control that is strongly typed against a model class. This control is displayed on the view several times but with differing property values, such as headings (Ex: Question 1, Question 2, Question 3, etc.. are all headings). I can write a custom...

My ASP.NET MVC2 application with Forms Authentication is blocking access even to Images, Styles and Scripts

Hi, I'm developing a MVC2 application and using Forms Authentication on it. The scripts, images and styles are all blocked to unlogged users and, consequently, the login page looks awful. It works well local, the problem is when I publish to the server. Does anyone has any idea WHY???? PS: The server IIS is version 7.5 My Web.config...

Multiple ActionResults to return same view? Or better way?

I have the url route working like so [domain]/Listings/Colorado the Action results signature to return the model works fine ...ActionResult GetByStateName(string stateName).. I'd like to have the same view returned by an ActionResult GetByStateName(string stateName, string priceRange) ...overloading I guess but I can't have ambiguous ac...

Create non aspx views (e.g. WML) with ASP.NET MVC2

Hi, Using ASP.NET MVC2, how would I go about creating a WML view for a given controller action? (Or any other non-aspx view for that matter). E.g. http://localhost/Store/Browse would actually return a text/vnd.wap.wml response. <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1...

How to change the starting page of the project?

I create a new project and start it. It turns out that the controller Home is called with the action is default i.e. Index - this means Controllers/HomeController.Index() is called. The view displayed by this action is defined in this method - i.e. Views/Home/Index.apsx. I want to change this starting behavior to be another controller a...

String.Format in lambda expression with For helpers

Is it possible to format inline with String.Format inside edit forms where you use lambda expression with TextBoxFor HTML helpers? Something like this but this obviously fails but hopefully you will get what I mean <%: Html.TextBoxFor(String.Format("{0:d}", model => model.IssueDate), new { @class= "invoiceDate"}) %> ...

How to specify date format for model binding?

I hope the question is easy, but I am searching around for more than an hour and I just do not find the answer. So I have a asp.net mvc 2 application and one of the forms contains a date textbox with a jquery datepicker. I have set in the datepicker the date format to be dd.mm.yyyy. My problem is that on the model binding this date is in...

SparkViewEngine does it work with asp.net mvc Vs2010.

Hello, I am trying to use new spark view engine . i have done all necessery configuration as mentioned here http://dotnetslackers.com/articles/aspnet/Installing-the-Spark-View-Engine-into-ASP-NET-MVC-2-Preview-2.aspx and Have below Erorr message on run time..what am i missing? AS in understand Spark view engine uses system.web 2.0 ...

MVC 2 - two radio button group persist state

Hi Guys, I have two radio button groups in my partial view and based on the selections of two I have to manipulate an "Extension Area (div)". The requirement is to default the radio button groups to first ones by default and show the Extension Area relevant to it. The problem is when there is a validation error I am not able to persist ...

Which is the another option rather than LINQ to SQL in ASP.NET MVC?

HI, I am currently using the ASP.NET MVC pattern for my small application. I am using LINQ to SQL to manipulate with objects of model. I am using lambda and queries to manipulate. But as i found lot of limitations with LINQ to SQL concept I am planning to remove. so which is the best option rather than LINQ to SQL for manipulation with d...

Visual Studio 2010 Unit Test not showing in Dropdown menu

I installed NUnit to show up in the Test Framework dropdown menu in Visual Studio 2010. The setup went good and NUnit now shows up in the Test Framework dropdown menu for my ASP.NET MVC2 projects. My problem is the Visual Studio Test has disappeared from the Test Framework dropdown menu. I ran a repair on Visual Studio but that did not r...

ASP.NET MVC combo dropdown box

Hi, Is it possible to create a dropdown box in ASP.NET MVC, that has a checkbox alongside each item in the dropdown list? I know it sounds simple, in webforms or using telerik this would be pretty simple, but I can't figure how I can implement the same thing in basic HTML. Thanks ...

Complete examples using MVC2, EF4, and Repository Pattern with true SoC

I'm having trouble finding examples of ASP.NET MVC solutions that use EF4 in their repository while adhering to SoC. Can anyone provide me with references to examples (open source, books, tutorials, articles, etc.) that demonstrate the following? ASP.NET MVC 2 Entity Frameworks 4 Repository Pattern Separation of Concerns (i.e. BL does...

Page needs to inherit 2 view models and show whichever model thats required

Hi, I have a content page which is quite happy to show inherit a contentModel. I need to change the page so it can also show another viewModel (e.g. revertedContent), but only show it if it needs to other show the normal contentModel. I'm sure there is a simple way to do this it's just a pain as I need to ensure the page doesn't get ch...

Trying to write file to UNC from ASP.NET MVC

I have some code running in an asp.mvc app inside IIS 7. The code is supposed to save a file to a UNC share. This function is called from some controller code, with the filePathname = "\MYSRV\sites\docs\10080003\egg.txt' public void EnsureDocument(string filePathName ,string content,WindowsIdentity identity ) { System.Security.Princi...

ASP.NET MVC: Member with the same signature already exists error

I have two controllers with the same name. One with a [get] and the other with [post]. These two perform totally different functions. Why can't they be the same name? [AcceptVerbs(HttpVerbs.Get)] public ActionResult AddCriteriaItem(CriteriaItemAddFormCollection ciafc) { return View(ciafc); } ...