asp.net-mvc-2

ASP.NET MVC 2 disable cache for browser back button in partial views

I am using Html.RenderAction<CartController>(c => c.Show()); on my master Page to display the cart for all pages. The problem is when I add an item to the cart and then hit the browser back button. It shows the old cart (from Cache) until I hit the refresh button or navigate to another page. I've tried this and it works perfectly but it...

Trying to add functionality to MvcHandler

I am currently trying to add 301 redirect to my routes in MVC to do this I have tried to inherit from the MvcHandler. The handler gets instantited with the right values. but I am never able to debug the overridden methods. can someone show me a working attempt at this? the asp.net pipe simply seems to the doing its own thing... pub...

ASP.NET MVC Model Binders, html id

Using the Model Binders in ASP.NET MVC 2.0, you can do something like this... [DisplayName("User Name")] public string Name { get; set; } <%: Html.TextBoxFor( m => m.Name ) :%> and then in your HTML, you get a result like this.. <label for="UserName">User Name</label> <input type="text" id="UserName" name="UserName" /> That work...

How would you organize this in asp.net mvc?

I have an asp.net mvc 2.0 application that contains Areas/Modules like calendar, admin, etc... There may be cases where more than one area needs to access the same Repo, so I am not sure where to put the Data Access Layers and Repositories. First Option: Should I create Data Access Layer files (Linq to SQL in my case) with their accomp...

How to change id value when using Html.DropDownListFor helper in asp.net mvc 2.0?

Hi I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName, Model.ProductList, "Select a Product") %> Now you can create a new product and edit a existing product. Both editing and creating use the same form. The create is on the main page on load up. Edit popus up in a jquery u.i model...

Possible to have empty values with Html For Helpers such as Html.TextBoxFor()?

Hi Is it possible to have to make a html for helper in asp.net mvc 2.0 have a default value of "empty string" Like if I do this Html.TextBoxFor( u => u.ProductName) would render to <input id ="ProductName" name="ProdcutName" type="text" value="Jim" /> Now I don't want the textbox to display jim. I want it to display nothing. <i...

Is ASP.net MVC a direct copy of Ruby on Rails concepts?

Hi, I'm been developing Ruby on Rails previously. I'm now looking at an ASP.net web app and I'm looking at WebForms and MVC. As I look at MVC it feels as if I'm looking at the result of something a Ruby on Rails developer implemented after being forced to work in MS land. So I'm wondering: Was MVC more or less taken directly from Ru...

RSS feed per tag

Hi. Suppose stackoverflow.com wanted to have an RSS feed per each tag. They would probably have requests like stackoverflow.com/rss?tag=aspnet to return appropriate RSS feeds. This is the easy part. Now when the user requested stackoverflow.com/rss?tag=aspnet he would see some XML. Instead it would be better to show a page where user ca...

How Does One Differentiate Between Routes POSTed To In Asp.Net MVC?

I have two actions, one that accepts a ViewModel and one that accepts two parameters a string and an int, when I try to post to the action, it gives me an error telling me that the current request is ambiguous between the two actions. Is it possible to indicate to the routing system which action is the relevant one, and if it is how is ...

another approach to returning some thing to browser in mvc with ajax call instead of using response.write

hi, i have one section in my mvc 2.0 project which doing some processes and after each, return some messages (string) with response.write(). and this messages returned to browser with bad format. i want to return messages to one specific HTML div and add each to end of contents of div tag. now how do this? this event after each procces ...

App_GlobalResources broken in ASP.NET MVC 2 and VS 2010?

Good day! I have installed VS 2010 Express and resource files in App_GlobalResources are not compiled into strongly typed Resources class. More specifically no more code generation take place. I have tested with my MVC project (updated from MVC 1.0 and VS2008) and with blank ASP.NET MVC 2.0 project generated by VS and got error (even ...

RedirectToAction for areas?

Hi, I have setup some areas, but I'm not sure how to Redirect to them via the RedirectToAction method. There doesn't seem to be any Area parameter I can feed it. Thanks ...

Strongly typed API for ASP.NET MVC 2 async actions

Hi guys, Have anybody tried to create strongly typed API for ASP.NET MVC 2 async actions? Best regards, Alexey Zakharov ...

Swap Master Page used in View from a value selected in a DropDownList

I have a mvc app that currently is branded to one brand. I want to add a user control that will hold a list of brands and when the user makes a selection the Master Page is swapped out, the styles will also be changed as the stlye link is held on the Master Page. Has anyone done this before, is it possible and if so can anyone please s...

Diff between <head id="Head1" runat="server"> and <asp:ContentPlaceHolder runat="server" ID="HeadContent">

Looking for an better understanding of how an mvc project should define javascript and css includes. I'm working with sample code where includes are defined like: <head id="Head1" runat="server"> <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" />Affiliate Checkout</title> <meta http-equiv="Content-Type" content="...

ASPNET MVC 2 LabelFor prefix overload

I refer to this question. The answer offered works really well but it doesn't seem to take the data annotation attributes for the DisplayNameAttribute into account when using the new labelfor helper. This is the code I am using: public static MvcHtmlString LabelFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, string prefix,...

ASP MVC 2 : Custom display of a required form element based on ModelMetaData

I have an MVC 2 application that utilises forms. The required fields within the form are set using attributes that update the model metadata. The form fields are created using the MVC HtmlHelper method : Html.EditorFor. This works fine so far as validation is concerned, but it seems that by default the required fields are not displayed ...

Spark show logged in user

How do I show the username of the person logged in within a Spark View? The default MVC view engine had a Page object that you could get the info from. How would I do that in spark? I know that I could put the info into the viewdata dictionary, which is probably the best, but I don't want to have to write ViewData["User"] = myUser; ...

ASP.NET MVC2 Model Validation Fails with Non-US Date Format

I have a small MVC2 app that displays in two cultures: en-US and es-MX. One portion contains a user input for a date that is pre-populated with the current date in the Model. When using en-US, the date field is displayed as MM/dd/yyyy and can be changed using the same format without causing any validation errors. When using es-MX, the...

Offline websites using Google Gears or HTML5

I have been reading about creating offline websites using Gears and using HTML 5. Im curious as to advantages and disadvantages of the two in regards to an ASP.Net MVC2 applcation with a SQL Database Backend. It seems to me that since Gears supports offline Database functionality. It would be the only way to go. But with some creativ...