viewusercontrol

Asp.net MVC User Control ViewData

When a controller renders a view based on a model you can get the properties from the ViewData collection using the indexer (ie. ViewData["Property"]). However, I have a shared user control that I tried to call using the following: return View("Message", new { DisplayMessage = "This is a test" }); and on my Message control I had this...

Can you create a strongly typed ASP.NET MVC ViewUserControl of type int or enum?

Hi folks, i wish to create a reusable ASP.NET MVC ViewUserControl which is strongly typed to an enumeration. Can this be done? When i try it, it says that the strong type the ViewUserControl can accept, can only be of a reference type :( This also means i can't pass an int as TModel. Why do i want to do this? I'n various places of my...

ASP.Net MVC ViewUserControl with controller using MVC 1.0

Because of the confusion between all the info that is out there about mvc from all the preview releases and the one official release I am very confused how to deal with viewusercontrols. So once and for all, tell me how to implement this example: I have a list of upcoming events that needs to be displayed on several pages of my website....

ASP.NET MVC ViewUserControl: How do I load its scripts dinamically?

I have a ViewUserControl that will be used in some pages in my site, but not all. This ViewUserControl requires a javascript file, so I would like to have the script reference added automatically to the head session of the pages that are using this ViewUserControl, is that possible? I tried to add a content control to it, but looks like ...

When I click to open a ViewPage or a ViewUserControl Visual Studio 2008 hangs for me

When I double click on a ViewPage or a ViewUserControl in Visual Studio 2008 the whole application hangs for me, I have no idea why... The only error log I can find in the Event Log is this: .NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506) For more information, see Help and Support Center at htt...

ViewUserControl and MVC

I'm dynamically adding ViewUserControls to a view. I pass a collection of virtual paths to the view and the view iterates through and renders each ViewUserControl using RenderControl(MVCToolKit). My question is, upon a POST, how do each of the ViewUserControls handle and get the data posted back? ...

asp.net mvc - Views and Controllers

How do controllers know which views to return? I thought it was by naming convention, but I have seen instances, for example in the Nerd Dinner application, where the names don't match. Where or how do I see this mapping? Thanks. ...

ASP.NET MVC - Contained User Controls

I want to be able to create ViewUserControls with their own controllers so all the logic is contained completely. Right now, I have to wire up the ViewUserControls with the main controller and if I wanted to use these viewUserControls elsewhere, I would have to wire them up again. Is it possible to do what I'm hoping for? ...

MVC - Dynamically loading Partial Views

I'm trying to dynamically load partial views into a view by passing the list of paths for the partial views I want and then calling RenderPartial on each. This seems to do the trick. The problem comes in when I try to pass the model to the partial view. Since I'm dynamically loading them, I don't exactly know which model to pass for t...

Can you use MVC 2 Strongly Typed Helpers in Partial View?

I'm trying to use the new strongly typed helpers. I've inherited the Model in my Control: Inherits="System.Web.Mvc.ViewUserControl" but intellisense isn't exposing the model and the page isn't happy with it if I force the code in. If I do it in a standard View all is good. This is what I'm expecting to be able to do: <%= Html.LabelFor...

name 'html' nor name 'model' exist in current context in usercontrol MVC and C#

I am using Microsoft MVC and C#. I have a usercontrol (example.ascx) created and at the top I'm inheriting System.Web.MVC.ViewUserControl<PostTransferViewModel> Now, while my model name is appended to ViewUserControl, I get "The name 'Model' does not exist in the current context" and "The name 'Html' does not exist in the current contex...

Rendering a derived partial view with Html.RenderPartial

Calling Html.RenderPartial("~/Views/Payments/MyControl.ascx"); from a view works if MyControl.ascx is a control that directly inherits System.Web.Mvc.ViewUserControl. However, if the control inherits a new class that derives from System.Web.Mvc.ViewUserControl, the call to Html.RenderPartial("~/Views/Payments/MyDerivedControl.ascx"); f...

How to pass data from view to UserControl in ASP.NET MVC?

Say I want to do the simplest of the data passing as follows : <% For i = 0 To 10%> <%Html.RenderPartial("MyUserControl")%> <% Next%> What I want to do is to pass the variable i as the parameter to the UserControl so that it displays the number inside a, say, bordered div. How is this possible? Thanks ...

Asp.Net MVC2 Clientside Validation problem with controls with prefixes

The problem is: when I put 2 controls of the same type on a page I need to specify different prefixes for binding. In this case the validation rules generated right after the form are incorrect. So how to get client validation work for the case?: the page contains: <% Html.RenderPartial(ViewLocations.Shared.PhoneEditPartial, new Ph...

How do I encapsulate form/post/validation[/redirect] in ViewUserControl in ASP.Net MVC 2

Short verion: need ViewUserControl (i.e., Login Form) to post to self and be able to redirect (i.e., on successful login), or return original View (i.e., Home/Index) with validation summary and not interfere with other ViewUserControls on the page. Also, HomeController/Index should have minimal knowledge of Login Form's inner workings. ...