javascript - MVC - Using Viewbag variable to determine Partial View not working -


i set viewbag variable (flag) determine partial view show in shared layout view. partials set of icons. when "more" icon clicked want swap in different partial different set of menu icons. "more" icon click code set in layout javascript:

$(function () {      $('#moreicon').click(function () {         $.ajax({             url: 'home/loadmoreicons',             datatype: "html",             success: function (data) {             }         });     }); }); 

the controller action is:

public emptyresult loadmoreicons() {      viewbag.arrowclick = true;     return null;  } 

the _layout view (razor) code is:

    <div id="headicons">     @if ((bool?)viewbag.arrowclick == false)     {         @html.partial("mainiconspartial")     }     else     {         @html.partial("moreiconspartial")     } </div> 

whats happening "else" logic never happens though can break @ point viewbag variable getting set in controller action when "more" icon clicked.

my bad ... missed set of viewbag variable set.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -