MVC Rendering (RenderPartial, RenderAction) Html From Another MVC Application

Sep 9, 2010

I am working in an environment with many teams who are responsible for specific content on pages. Each team is sharing specific information (common class libraries, and master pages) that each are going deliver different types of content.Is it possible for an MVC application to do something similar to RenderPartial and pass a model to another MVC application Controller/Action to return content?

So the code for this might look like:

<% Html.RenderAction("", "Home", "Index", AdModel) %>

Maybe this is not a good idea as another thread has to spin up to server a partial view?

View 2 Replies

Similar Messages:

MVC 2.0 - Difference Between RenderPartial And RenderAction

Oct 19, 2010

I am trying to understand the difference between a RenderPartial and RenderAction. I guess that RenderPartial is like a UserControl and RenderAction is like a server-side include.

View 3 Replies

Html.ActionLink() Gives An Empty Link When Use It Inside Html.RenderAction()?

Feb 18, 2010

I have a Microsoft MVC project with an action "Foo" whose view ("Foo.aspx") contains the lines:

<%= Html.ActionLink("mylinktext1", "bar") %>
<%= Html.ActionLink<MyController>(x => x.Bar(), "mylinktext2") %>

When I hit this from a web browser or load it from an AJAX call, it properly returns:

<a href="/bar">mylinktext1</a>
<a href="/Bar">mylinktext2</a>

But when I call the action from another view like this:

<% Html.RenderAction<MyController>(x => x.Foo()); %>

Then the links are rendered without targets.

<a href="">mylinktext1</a>
<a href="">mylinktext2</a>

Why would this be happening, and how do I work around it?

View 1 Replies

MVC :: Whats The Difference Between Html.Partial And Html.RenderPartial

Sep 27, 2010

Whats the difference between Html.Partial and Html.RenderPartial?


View 1 Replies

C# - Difference Between Url.Action And Html.RenderActionLink And Html.RenderAction

Apr 12, 2010

Whats the difference between Url.Action and Html.RenderActionLink in mvc?

View 1 Replies

MVC: When To Use Custom HTML Helper Methods Vs Html.RenderAction

Feb 10, 2010

It's a little unclear for me on when to use a custom helper method and when to use RenderAction and also when to simply use ViewData instead. Some of their functions overlap slightly.

For example, if I were to create a Category navigation bar, would I create a new helper method and place that in some partial view? I had initially though of doing this, but I read on some blog to use RenderAction instead.

Assume the list of categories is coming from some data source.

View 4 Replies

Difference Between Html.RenderAction And Html.Action?

Jun 2, 2010

Does anybody know what's the difference between Html.RenderAction and Html.Action?

View 2 Replies

MVC :: Creating A Widget With Html.renderpartial?

Apr 29, 2010

I have an action that generates active vacancies. The code is below;


I want to use this list on several pages so i guess the best thing to use is html.renderpartial.

I then created a view by right clicking inside the action and create a .ascx and a strongly typed view of Vacancy. I chose a view content of "List".

I then added this line to the required page;


View 12 Replies

.net - Call The RenderAction In Html Helper?

Feb 17, 2010

im extending the htmlhelper. but it i cannot call the renderaction of it.

using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
public static class ViewHelpers
public static string Text(this HtmlHelper htmlHelper, string name, object value, bool isEditMode)
htmlHelper.RenderAction(...) //cannot be called

how can i call the RenderAction?

View 2 Replies

Mvc3 Html.renderpartial On Master Page?

Nov 23, 2010

im getting the following exception for use into a master page the helper html.renderpartial(). This works on mvc views that uses this master page, but im trying to execute an old aspx webform page that uses the same masterpage. And here comes following exception:A ViewMasterPage can be used only with content pages that derive from ViewPage or ViewPage.This is the code of my master page:

<%Html.RenderPartial("PartialView"); %>
<div style="background-color:Aqua;">
<asp:ContentPlaceHolder ID="MainContent" runat="server">

I would like to render some partialviews on my master page. Is it possible?

View 1 Replies

MVC :: Determining If There Is Content In A ContentPlaceHolder When Using Html.RenderPartial

Sep 17, 2010

What I'm trying to do is use one master page with two different layouts. Currently we have a "master" master page that has all the common elements and two master pages that use it for the two different layouts. This gives us 3 master pages and there's developer confustion and it is a bit of a hassle to keep them consistent. What I'd like to do instead is say "if there's anything in the MainContent ContentPlaceHolder, show the single column layout, otherwise show the two column layout".

From what I've read you're supposed to be able to do this by using something like the following:


But this.MainContent.Controls.Count retuns zero when the ContentPlaceHolder uses Html.RenderPartial. For example, this works fine:


This causes this.MainContent.Controls.Count to return 1. If I remove MainContent from the view, it returns 0, as expected. However, if I do this:


Then this.MainContent.Controls.Count returns zero.

View 2 Replies

Get Html.RenderAction To Call The Get Method On A Post?

Sep 21, 2010

After rendering a view on a Post, a call to RenderAction inside the view will call for the Post method. Is there any way to specify I want to call the Get method instead of the Post?

View 1 Replies

MVC :: Output Caching For A View That Is Rendered From Html.RenderPartial

Jul 9, 2010

Ive tried [OutputCache] for a view that is rendered from Html.RenderPartial, but it doesn't work! It works perfectly for 'normal' views.

How do I cache output for partial view?

View 2 Replies

MVC :: RenderAction() Ignores Model Validation, RenderAction() Does Not?

Jun 4, 2010

I'm using MVC 2 and MVC Futures 2.0.50217.0.

I started with a view which repeatedly calls RenderAction(...) to include some external content implemented by another controller in my application. This is from the containing view:


The subModel objects are instances of the model for the MyController.MyAction view which has some Data Annotations validation attributes upon it. MyController.MyAction checks the model state is valid before it renders its view and chooses a view appropriately. This works fine.

However, if I use the MVC Futures' strongly typed helper to call RenderAction like so:


...then the validation is not performed. Or at least, the model state does not indicate that the model is invalid.

View 7 Replies

MVC :: Html.RenderAction In MasterPage Expects Home Controller?

Jun 28, 2010

In my Site.Master View, I have the following line:


If I don't include the string identifying the Controller to use, I get an error stating that the PrimaryNavigation method couldn't be found in the Home Controller. Since the Site.Master View is in the Shared Views folder, I would have thought that the Shared Controller would have been used.

View 1 Replies

MVC :: Assign Records Entered From A User Control By Html.RenderPartial?

Jan 6, 2010

I have a question for use Html.RenderPartial.

How do I assign records entered from a user control by Html.RenderPartial the model of objects of my main view?

Today when I try to save my record can not save the record of association with only the records of the Main View.

Basically the operation of the screen is the following, make the creation of a parent record and then join the other records. I want to save the parent record and associated records.

View 1 Replies

MVC :: Html.RenderPartial Appears To Be Stripping Model Of Custom Attributes

Aug 27, 2010

I have implemented a custom ModelMetadataProvider so that I can decorate my view models with some custom attributes and everything was working fine until I made use of a Partial View. The following code in my view works fine: -

<%: Html.DisplayFor(x => x.Results) %>

Results is a List which renders a custom display template and is also decorated with a custom attribute. Using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked. If I look at the attributes collection parameter I can see that it does contain my custom attribute thus everything working as expected. However, if I replace the above with the following line of code in my view then it breaks: -

<% Html.RenderPartial("ApplicationSearchResults", Model.Results, new ViewDataDictionary()); %>

All the Partial View contains is: -

<%: Html.DisplayFor(x => x) %>

Again using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked. But this time if I look at the attributes collection parameter my custom attribute is not there.

View 4 Replies

MVC :: Load Partial Views Dynamically At Runtime Using Html.RenderPartial?

Jun 8, 2010

The following link describes the relationships between a Partial View and its parent in terms of ViewData: [URL] In relation to the text: "A partial view enables you to define a view that will be rendered inside a parent view. Partial views are implemented as ASP.NET user controls (.ascx).

When a partial view is instantiated, it gets its own copy of the ViewDataDictionary object that is available to the parent view. The partial view therefore has access to the data of the parent view. However, if the partial view updates the data, those updates affect only the partial view's ViewData object. The parent view's data is not changed"

how the parent view can make use of the new data added or existing data changed and updated, by the partial views? My question is around how to load partial views dynamically at runtime using Html.RenderPartial(...) whilst having one version of the data used and updated by the parent view and it's children.

View 4 Replies

MVC :: Get ViewDataDictionary Value In Controller Passed From User Control (Html.RenderPartial)?

Jul 26, 2010

I am unable to get value in controller with below code.

<tr style="border-style: none">
<% ViewDataDictionary dictionary = new ViewDataDictionary();
<td colspan="4" style="border-style: none">
<% Html.RenderPartial("Pager", Model.hangTagPagedList,new ViewDataDictionary(dictionary); %>

Is there any way to get it.

View 1 Replies

MVC :: HttpException In Html.RenderAction After Installing Visual Studio 2010 Pro RTM?

Apr 13, 2010

I get an HttpException (details below) after installing Visual Studio 2010 Pro RTM in an application developed using Visual Studio 2010 RC. The platform used was ASP.NET MVC2 RTW (already under VS10 RC).

I first uninstalled all RC software and even ASP.NET MVC 2, and then did a "clean" install of VS10 RTM. The ASP.NET MVC 2 version now installed on my dev machine is 2.0.50217.0.

Exception Message: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

InnerException Message: <FilePath>ViewsLanguageRenderLanguageNavigation.ascx(6): error BC30451: 'Model' is not declared. It may be inaccessible due to its protection level.

The error occurs on this "Html.RenderAction":


The "LanguageController" just calls into another service function as below:


Does anybody have an idea what is causing the problem?


By the way, I might also share the actual view (partial view) that would show the languages to select from:


View 1 Replies

MVC :: How To Pass The Value In Main View To Partial View When Using Html.RenderAction

Jan 27, 2011

Let's say there is a textbox and a dropdownlist in mainview page, these two values are used by three partial views as well. when I use Html.RenderAction to post action to those three partial views, how to pass these two values to those partial views and in those views how to get these two values as a part of a object to send to database.

View 10 Replies

MVC :: Rendering HTML From Database?

Jul 17, 2010

I have the following line of code in an MVC2 project but I cant get it to render the HTML from the database, all I that is displayed is the HTML.

<%: (Model.Blog.BlogDetail)%>

View 2 Replies

MVC :: Rendering Encoded Html?

Aug 13, 2010

I cannot seem to get over this problem. Im sure it is just a simple newbie question but I just cannot find the right answer on my own.

Im using MVC 2 and ASP. NET 4.0 to biuld simple CMS. Im storing encoded HTML in XML file which then i am passing to front page controller for display.

I understand that before inserting HTML from XML into the page, it should be decoded using HttpUtility.Decode() function.


I expected that this sould result in inserting decoded HTML into my index.aspx page. Then browser could render my decoded content for example in bold face.

What happens is quite awkward. In page source I have encoded HTML but it renders HTML with tags. For example I see "<strong> Lorem ipsum </stong>", instead of Lorem Ipsum.

View 5 Replies

Html - Rendering Of .net Controls?

Mar 10, 2011

I find it hard when using controls, to make proper css files because I don't know what the html output for the different controls end up as. For example, if I want to add a div tag using a control, it's not easy to know what kind of control I can use.

Are there any documentation that shows for each control, what the rendered html for that control will be? I understand that some controls will probably change it's output due to how it's configured, but most controls will at least follow a pattern here.

The best would of course be a service on the web where you can put in the control definition and get the rendered html out. Currently I have to put a control into my webform, run it and check the source in the browser, and if it's not the correct html tag, try another control and repeat. That get's tedious quite fast.

View 2 Replies

MVC Html Helper Rendering?

Jan 20, 2010

I was wondering if it's possible to render an Html Helper in a View inside a codeblock. So instead of:


And have this render. Of course as it is, it wont render, so is there a way to programically decide if a textbox can be added without having to have a million delimiters in the page to accomplish this?

View 2 Replies

Copyrights 2005-15, All rights reserved