//Instead of this,
@Html.Action("MenuLayout", "Menu")
//you should use
@Html.Partial("partial1", "Controller1")
//You should create two partial _MenuPartial and CreatePartial
//In your Shared/Layout
@if(cRoldId == null)//or any other condition depending of your variable
{
@Html.Partial("MenuLayout", "MenuController")
}
else
{
@Html.Partial("Create", "Issue")
}
Если вам нужно сделать это после загрузки страницы или любой другой транзакции, вы можете использовать ajax-вызовы:
в вашем контроллере меню:
public ActionResult MenuLayout(string cRoldId)
{
if (cRoldId == null)
{
return PartialView("Create"); //Create must be in the controllers folder.
}
else
{
return PartialView("MenuLayout"); //menu layout must be a partial view.
}
}
<script type="text/javascript">
//Executes on load event of the document
$(document).load(function(){
function printProjectFiles() {
$.ajax({
url: '@Url.Action("MenuLayout", "Menu")',//MenuLayout is your method name, Menu is your controller name
type: 'GET',
data: {cRoldId :"yourParamValue"},
dataType: 'HTML',
success: function (result) {
$("#myNavbar").html(result);//returns a partial view and inserts it into your control.
},
error: function (err) {
}
});
}
});
</script>
Скажите, работает ли он?