asp.net - Getting error in mvc4 -
error:-
error executing child request handler 'system.web.mvc.httphandlerutil+serverexecutehttphandlerasyncwrapper'.
my main page view this
{ viewbag.title = "start"; } <h2>start</h2> <script type="text/javascript"> $(document).ready(function () { $("#test1").click(function (e) { $("#firstpartialview").css("display", "none"); $("#secondpatialview").css("display", "none"); $("#firstpartialview").css("display", "block"); }); $("#test2").click(function (e) { $("#firstpartialview").css("display", "none"); $("#secondpatialview").css("display", "none"); $("#secondpatialview").css("display", "block"); }); }); </script> <a id="test1"></a> <a id="test2"></a> <div id="firstpartialview">@html.action("firstview", "home") </div> <div id="secondpatialview">@html.action("secondview", "home") </div>
my controller this:-
public actionresult start() { return view(); } public actionresult firstview() { modela obja = new modela(); return partialview(obja); } public actionresult secondview() { modelb objb = new modelb(); return partialview(objb); }
my partial view this
_partiala.cshtml @model demo3.models.modela @{ viewbag.title = "_partiala"; } <h2>_partiala</h2> <div>@html.editorfor(m => m.employeeid) </div> <div>@html.editorfor(m => m.employeename)
and partial view this
_partialb.cs.html @model demo3.models.modelb @{ viewbag.title = "_partialb"; } <h2>_partialb</h2> <div>@html.editorfor(m => m.comapny) </div> <div>@html.editorfor(m => m.fisacalyear) </div>
please me solve error..on browser error coming
the partial view 'firstview' not found or no view engine supports searched locations. following locations searched:
~/views/home/firstview.aspx
~/views/home/firstview.ascx
~/views/shared/firstview.aspx
~/views/shared/firstview.ascx
~/views/home/firstview.cshtml
~/views/home/firstview.vbhtml
~/views/shared/firstview.cshtml
~/views/shared/firstview.vbhtml
the error means mvc trying load file (by default, if haven't specified view file name, checks action name in case, firstview), can't find it.
you can specify view file name in return statement:
return partialview(string "view", object model)
this can used (assuming _partiala view's cshtml filename):
return partialview("_partiala", obja);
Comments
Post a Comment