partial-views

Rendering one partial view in two different strongly typed views

I have a strongly typed Person view, that I want to render a partial in: Person View (strongly typed as person) <label for="name">Name</label> <% Html.RenderPartial("AddressForm"); %> </label> AddressForm View (untyped, because I also want to use this in the Distributor strongly typed view) When I try to call this partial from t...

clever universal form partials in rails

I have a widget for currencies which I use throughout my application. Ie. the user changes the currency from EUR -> USD, or about 13 other currencies. I have a few other use-cases such as dates but this one is the easiest to explain. Currency basically just updates a session variable by calling the currency controller and then uses so...

Partials With View Data Object

I have the following ViewData that I pass into a view. public class MerchantSignUpViewData : BaseViewData { public Merchant Merchant { get; set; } public Address Address { get; set; } public Deal Deal { get; set; } public List<MerchantContact> Contacts { get; set; } public int TabIndex { get; set; } public List<D...

How can I make a partial view re-usable across different viewmodels (asp.net mvc 2)?

I have created a partial view that I'd like to be able to re-use on different pages of my website. Currently, for each webpage I create a ViewModel that collates all the information I would like to show and then I send it to the view which compromises of 3 separate partial views. Here is a simplified example: public ActionResult Index(...

Rails 3: Where should a helper that uses h (i.e. html_escape) live?

I'm writing a webapp in Ruby on Rails 3. Rails 3 automatically escapes any potentially-bad strings, which is generally a good thing, but means if you assemble HTML yourself, you have to call html_safe on it. I have a Card model, which has several text fields, the contents of which are not trusted (may contain evil HTML or script). I hav...

MVC2 Partial View - Code behind

I'm creating an MVC2 site which is a new, refreshed version of a site built in Web Forms. Due to the nature of some of the features and the a database of statistics and their structure there is no one-size-fits-all way to display some of the information needed to be displayed. Thus, despite following MVC principles elsewhere, in one fe...

Difference between MVC 3 Partial Page (Razor) and MVC 3 View Page with Layout (Razor) ?

In MVC 3 Beta, is there a difference between the templates MVC 3 Partial Page (Razor) and MVC 3 View Page with Layout (Razor) ? I added a partial page (_partialList) to my application. Now when I return only the partial view, it applies the Layout present in _ViewStart.cshtml - acting very much like a stardard view page with layout. ...

What's the current practice for partial caching in ASP MVC2?

My website pages are composed of two kinds of content. The first is variable between users but constant for all pages. The second is constant across users, but variable between pages. This is a common layout. What is the best way to apply output caching to content like this? As I understand it, the Html.Substitute helper is incompatible...

Dynamically added, strongly typed partial views do not see the Model

Here's my scenario: I have a view with a dropdown list and when the user selects an item in the list I want to dynamically insert a partial view which is strongly typed with the same Model as the parent view. I thought this was a fairly common scenario and would be pretty easy to do but I may have been mistaken (or just inexperienced). ...

ASP.Net MVC 2 partialview that reads part of URL

Hi all, i am creating a partialview with a controller action like: public ActionResult GetPostsByUser(string userName) { where userName is part of the URL: www.example.com/User/toddM toddM being the userName First off.. am i going about this the right way?? if i make it a querystring ?userName=toddM it works.. but i need it ...

ASP.NET MVC 2 Ajax form submit, error: returns error with no information?

Hi All, i have a partial view with a form in it. It is strongly typed. I am using ajax in a view with the partial view in it to submit the form. It's basically a form that creates a new DB item and i can see that the controller action is working and being called. my ajax submit looks like this: $(document).ready(function () { v...

ASP.NET MVC 2 strongly typed partial view for foreign key list - what type gets passed in?

I would like to pass the item list for a drop-down list into a strongly-typed partial view. The parent view uses a ViewModel class that contains the properties both for the value I want to set and the list of options the associated drop-down list should contain. My ViewModel looks like: public class EntityFormViewModel { private My...

Order for ForEach on View Model

In MVC 2 I have a user control - Partial page as below. Model has four records id Dtext Dtext1 1 A, A1 2 B B1 3 C C1 4 D D1 On My machine - Output is as above in the ID Order which is expected. But after deployment output is totally bizarre something like below. D D1 B B1 A, A1 C C1 Would like to know ...

Viewing CSS Intellisense in partial views and Content pages - Visual Studio 2010?

I am trying to figure out how to get Intellisense for CSS to render when in a partial view or a content page. Of course I don't want it to render a runtime, as the css comes from the masterpage. I found this trick.... <%if (false) {%> <link rel="Stylesheet" href="styles.css"/> <%}%> But is there a better option? ...

ascx file error in MVC

Hi guys, I'm trying to render a partial ascx view within another view. I have the following error however in my ascx file, and after some research I'm still in the dark!: Type or namespace definition, or end-of-file expectedend-of-file expected Here is the code in DinnerForm.ascx <%@ Control Language="C#" Inherits="System.Web...