asp.net-mvc-2

Example of a simple ASP.NET MVC + NHibernate + Fluent with proper session handling?

I'm new to all of these technologies. I would like to see a simple (not over the top) example of how you would set up a project with these technologies. The most important being the proper NHibernate session handling (using HttpContext). Or we can build off of what I already have. I've seen several examples of one piece or another but n...

ASP.Net MVC Submit Post Data for Survey

I'm having a hard time figuring out how to collect the data from a FormCollection when submitted for my form which collects the answers for a survey. Specifically my problem is with questions that have multiple choice options(radio buttons) and an other textbox field if the options did not apply. My survey has the following structure: ...

using if else with LINQ Where

I want to generate dynamic query to check manage the where clause with number of parameters available...if some parameter is null i don't want to include it in the where clause var test = from p in _db.test where if(str1 != null){p.test == str} else i dnt wanna check p.test I have around 14 parameters for the where clause ...

IIS7 with MVC2 cannot load static resources

Hi, my situation is: windows7 visual studio 2010 (with mvc2) mvc2 web application compiled with .NET 3.5 I install IIS7 with StaticModule but when I try to load a css or an image I receive a blank page. Only html is loaded. Help me please. Thanks ...

Returning page HTML from ASP.NET MVC View

Hi Guys, I have a view That Renders 3 grids what I would like to do is on the click of button return the page as a string so I can save the HTML of that Page. is this possible? Thanks ashga ...

Formatting nullable DateTime fields in strong typed View

Hello, I have a Person class with a BornDate property in my model defined as [DisplayName("Born Date")] public DateTime? BornDate { get; set; } I use this field in my view as <td style="white-space:nowrap"> <%= Html.LabelFor(model => model.BornDate)%> <br /> <%= Html.TextBoxFor(model => model.BornDate, new { id = "bornD...

T4MVC: Cannot use a leading .. to exit above the top directory

Hi, I'm trying to use the T4MVC project from the MVCContrib project on codeplex (v2.6.13). I'm using ASP.NET MVC 2 RTM running against .NET 4 in Visual Studio 2010. Using the Default project template that you get when creating a new MVC 2 Web Application I modified the Home ActionLink in the Master Page to: <%= Html.ActionLink("Home", ...

How to create comparison validator MVC2

i have 2 properties int MinValue int MaxValue I have to create a data annotation attribute to validate this it should say 1)"MinValue should be less than MaxValue" if MinValue and MaxValue are not zero. 2)it should not compare the two values if both MinValue and MaxValue are zero(0). any input from you to achieve this will help me ...

how can mvc return Unauthorized code without redirecting to LogIn view

My MVC web application serves two types of users. First one over standard web browser Second one over REST returning only Json data. Both requires Authentication and authorization. Both scenarios are differentiated based on the route so that i know what content to serve. When users access the application, if they are not logIn the appl...

Enabling Client-Side Validation in ASP.NET MVC 2 and AJAX

Scott Gu wrote an excellent article explaining how to apply the Data Annotation validation in ASP.NET MVC 2. I have implemented the items in this article for the server-side work, and it works well. I get back error messages when there is a problem. I tried to add the code to also hook in client-side error messages (so a message is disp...

why I am getting HTTP/1.1 500 Internal Server Error?

Hello, In have a controller class that handle a Contact object. In this controller I have defined some actions like the two I am showing here public ActionResult Edit(int id) { ContactModel cm = loadContactModel(id); cm.ModelState = ModelStateEnum.Edit; return PartialView("Contact", cm); } public ActionResult AddAddress(in...

What are the key concepts to know when migrating my mindset from ASP.NET to ASP.NET MVC (2) ?

I'm currently working with ASP.NET and about to start learning ASP.NET MVC (2). So before I open the first thick book and go through the first lengthy tutorial, what are the most important (new) concepts to keep in mind? What are the main new features I should be aware of? Thanks a lot. ...

Invisible borders in html table not quite invisible?

I have some tables in my asp.net mvc application for layout purposes. Even though I usually use divs for most things, in some cases tables make most sense because they already have exactly the layout I'm after in these cases. The only problem is, as far as I know the borders are supposed to be invisible unless you specify a width and st...

ASP.NET MVC2 Master Page - Server side script not rendering, first bracket being escaped

I have a master page which I am using as a template to allow me to define meta tags per page. My master page takes in a model which contains the meta information, here is an example of what I am trying to do the following: <meta name="description" content="<%= Model.description %>" /> <meta name="keywords" content="<%= Model.keywords %>...

How to make ExtJs DatePicker in my MVC site ?

Hi. I need a datepicker widget via ExtJs on my pages that works like this. All I found in ExtJs are DatePicker and This sample with pickers The problem is that standart DatePicker looks like just a huge calendar with "today" button. The sample gives picker that looks like i want(textbox field and calendar on demand) but it works in ...

ASP.Net MVC Repository Question

I have 4 different models that I'm pulling information from for a grid in a view. This code excerpt is apart of my controller for my Index action. Each Model has a repository, partRepository, parts_comboRepository, vendor_partRepository, and manufacturer_partRepository, and i use those repositories to grab data for my joins. ...

Folder structure in ASP.NET MVC2

Hi all, I have a problem with folder structure of MVC2 How can I use that way: Folder: Controllers --Portal ----Accounting ------CashController.cs ------BankController.cs ----HR ------EmployeesController.cs Models Views --Portal ----Accounting ------Cash --------Index.aspx --------List.aspx ------Bank --------Index.aspx ------HR ------...

Where is strong-typed HtmlHelper extension method source codes in MVC 2 project ?

Hello everyone I wanted to see source code of HtmlHelper extension methods which takes ExpressionTree parameter but I could not find it in codeplex.com. Why ? ...

Translate asp.net mvc 2 application?

I'm hoping this is a rather simple question, but I'm pretty new to MVC and can't see clearly how it should be done. I have a site that I need to translate to another language. I've tried to search on this, but all I found was pretty complex translations about how to handle strings etc in resx files. That may be something for later, but f...

Unexpected behaviour on deploying MVC app.

Hi there, today I have deployed my first MVC 2 application on Windows Server 2008, and something strange happen. Authentication was requested on almost every pages, even to access 'scripts' and 'contents' folders. This was strange because this behavior doesn't occur on my development environment. Then I have setup IIS in my Win7, to t...