Questions tagged [viewusercontrol]
21 questions
28
votes
10 answers
Getting a Partial View's HTML from inside of the controller
I have developed a simple mechanism for my mvc website to pull in html via jquery which then populates a specified div. All is well and it looks cool.
My problem is that i'm now creating html markup inside of my controller (Which is very easy to do…

Andrew Harry
- 13,773
- 18
- 67
- 102
7
votes
2 answers
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…

Ryan Eastabrook
- 4,085
- 5
- 30
- 35
5
votes
1 answer
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…

Sasha
- 1,393
- 16
- 17
4
votes
1 answer
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…

Peter
- 14,221
- 15
- 70
- 110
4
votes
1 answer
Can you create a strongly typed ASP.NET MVC ViewUserControl of type int or enum?
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…

Pure.Krome
- 84,693
- 113
- 396
- 647
3
votes
2 answers
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…

Jey Geethan
- 2,235
- 5
- 33
- 60
2
votes
1 answer
T4MVC does not support DisplayTemplates and EditorTemplates
I've noticed this when I used the following in my view:
<% Html.RenderPartial(MVC.Shared.Views.EditorTemplates.ClientOnDocuments); %>
The line above returns just the name of the view, so in this case ClientOnDocuments. The default view engine then…

mare
- 13,033
- 24
- 102
- 191
2
votes
1 answer
How to handle situation when error happens during posting form from view user control?
I have a view user control that can post form. This control can be used on multiple views.
If user enters invalid data i add errors to ModelState - as simple as that. The problem is
that i don't know which view/actionresult to return since i don't…

michal zygula
- 183
- 2
- 8
2
votes
2 answers
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…

paul
- 21
- 2
2
votes
3 answers
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
Now, while my model name is appended to ViewUserControl, I get "The name 'Model' does…

J.B.
- 268
- 1
- 5
- 15
2
votes
2 answers
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…

Crios
- 237
- 4
- 6
2
votes
1 answer
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…

Crios
- 237
- 4
- 6
2
votes
3 answers
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.

Crios
- 237
- 4
- 6
1
vote
1 answer
ASP.NET MVC ViewUserControl: How do I load its scripts dynamically?
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…
Wookie-o
1
vote
1 answer
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…

Petrus Theron
- 27,855
- 36
- 153
- 287