This project is read-only.

ShapeResult partial BuildDisplay

Topics: General, Writing modules
Aug 12, 2011 at 2:54 PM

Is it possible to return an ShapeResult (by BuildDisplay) as Partial or as Html string? I really need this for my current project.

Aug 12, 2011 at 4:19 PM

Here is how I am doing in in the Taxonomy module. The scenario is to render a different list of values when a select has changed:

The Controller’s Action:

public ActionResult RenderTermSelect(int taxonomyId, int selectedTermId = -1) {

if (!Services.Authorizer.Authorize(Permissions.ManageTerms, T("Not allowed to manage terms")))

return new HttpUnauthorizedResult();

var model = new SelectTermViewModel {

Terms = _taxonomyService.GetTerms(taxonomyId),

SelectedTermId = selectedTermId


return PartialView(model);


The View:

@model Contrib.Taxonomies.ViewModels.SelectTermViewModel

@using Contrib.Taxonomies.Helpers;

@foreach (var term in Model.Terms) {

<option @if (term.Id == Model.SelectedTermId) { <text>selected="selected"</text> } value="@term.Id">@for (var i = 1; i <= term.GetLevels(); i++) { <span class="gap"> </span> }@term.Name</option>


The Javascript, using a technique to render it at the end of the Page:

@using (Script.Foot()) {

<script type="text/javascript">


$(function () {

$('#@Html.FieldIdFor(m => m.SelectedTaxonomyId)').change(function () {

var self = $(this);

var id = self.find("option:selected").attr("value");

// do nothing if no term

if(!id) return;


"@Url.Action("RenderTermSelect", "TermAdmin", new { area = "Contrib.Taxonomies" })", { taxonomyId : id }, function (data) {

$('#@Html.FieldIdFor(m => m.SelectedTermId) option[value != -1]').remove();

$('#@Html.FieldIdFor(m => m.SelectedTermId)').append(data);







Aug 12, 2011 at 4:19 PM

And if you need to render a shape, just call @Display(YOURSHAPE) from the View

Aug 13, 2011 at 3:29 PM

thank you Sebastienros! I already thought of this solutions but this requires me to do quiet allot async calls because i want to do this in Google Maps MarkerWindows. And for each marker i want to retrieve a part result.

This solutions is for now ok but i keep looking for a solutions  so i can directly parse the shape to a string result. Thanks allot!