Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
44 Points
112 Posts
May 08, 2012 08:46 PM|LINK
I have a Partial that I know that it is getting called and validated that it is receiving expected ViewData, but it does not always render.
Here is the partial:
@using WebUI.Domain.Digital @if (null != ViewData["SelectedRow"]) { CardDigital cardDigital = (CardDigital)ViewData["SelectedRow"]; string location = (string)ViewData["Location"]; <fieldset> <legend>Digital Card (@location)</legend> <div class="display-label"> FirstName</div> <div class="display-field"> @cardDigital.FirstName </div> <div class="display-label"> LastName</div> <div class="display-field"> @cardDigital.LastName </div> </fieldset> }
And here is the View code calling the Partial:
<div> <div> ... @if (grid.HasSelection) { ViewData["SelectedRow"] = new CardDigital((CardDigital)grid.SelectedRow.Value); ViewData["Location"] = "A"; } @Html.Partial("Partial/_DigitalPreview"); </div> </div> <div> @{ ViewData["Location"] = "B"; } @Html.Partial("Partial/_DigitalPreview") </div>
Notice that there are two locations "A" and "B". Both @Html.Partial receive the same ViewData["SelectedRow"], but only Location "A" is rendering. I validated that @Html.Partial at Location "B" is getting the data, but it just is not presenting it.
What could be the issue?
Thanks
jeff00seattl...
Member
44 Points
112 Posts
MVC3 Razor - @Html.Partial getting called but if it renders is based upon location
May 08, 2012 08:46 PM|LINK
I have a Partial that I know that it is getting called and validated that it is receiving expected ViewData, but it does not always render.
Here is the partial:
@using WebUI.Domain.Digital @if (null != ViewData["SelectedRow"]) { CardDigital cardDigital = (CardDigital)ViewData["SelectedRow"]; string location = (string)ViewData["Location"]; <fieldset> <legend>Digital Card (@location)</legend> <div class="display-label"> FirstName</div> <div class="display-field"> @cardDigital.FirstName </div> <div class="display-label"> LastName</div> <div class="display-field"> @cardDigital.LastName </div> </fieldset> }And here is the View code calling the Partial:
<div> <div> ... @if (grid.HasSelection) { ViewData["SelectedRow"] = new CardDigital((CardDigital)grid.SelectedRow.Value); ViewData["Location"] = "A"; } @Html.Partial("Partial/_DigitalPreview"); </div> </div> <div> @{ ViewData["Location"] = "B"; } @Html.Partial("Partial/_DigitalPreview") </div>Notice that there are two locations "A" and "B". Both @Html.Partial receive the same ViewData["SelectedRow"], but only Location "A" is rendering. I validated that @Html.Partial at Location "B" is getting the data, but it just is not presenting it.
What could be the issue?
Thanks
Jeff in Seattle