2
I need a control of a Partial View is displayed according to one condition. For some views a button would appear for others not and this would be set through a parameter in the call of Partial View.
After researching I saw that I can use ViewDataDictionary
, but when trying to implement I did not succeed.
For the control to be displayed on View the flame would be as follows:
@Html.Partial("_smart_actions", item, new ViewDataDictionary {{ "MenuClone", true }})
So that the control nay was shown in View the flame would be as follows:
@Html.Partial("_smart_actions", item)
Partial View:
<a href="@Url.Action("Details", new { id = Model.Id })" class="link-mutted" title="Visualizar">
<span class="glyphicon glyphicon-share" aria-hidden="true"></span>
</a>
|
<a href="@Url.Action("Edit", new { id = Model.Id })" class="link-mutted" title="Editar">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</a>
|
<a href="@Url.Action("Delete", new { id = Model.Id })" class="link-mutted" title="Excluir">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</a>
@if (ViewDataDictionary == true)
{
<a href="@Url.Action("DuplicarDados")" class="link-mutted" title="Duplicar">
<span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span>
</a>
}
Just do not trim the control, how to get around this problem?
I didn’t understand what the condition would be for Partial appear. I could explain this part better?
– Leonel Sanches da Silva
@Gypsy Morrison Mendez I will edit the question to be clearer.
– Jothaz
Hey @Jota, all right? If you can put the condition so that the partial appears, it would help. Type, user permission, url, etc. .
– Randrade
@Randrade Beauty brother! It would have no condition, because this Partial view would be used at all views. Only in some cases the Clone control will appear in others not. So I wanted to put a parameter in the partial so that I could reuse the entire project. But I managed to solve it. Of course I accept suggestions to improve the solution found.
– Jothaz