asp.net mvc - MVC 4 load partial view dynamically on single page -


i have mvc 4 application has single home view. have 3 link buttons , want load 3 different forms dynamically based on button click. using mvc partial views. so, if click on button-1 should load partialview-1 , should send value-1 corresponding text box partialview-1.

i looking mvc inbuilt approach rather doing heavy javascript work.

home page load partial views

you can this.

a. have different methods inside controller returning partialviewresult

[httpget]     public partialviewresult getpartialview1(int value)     {             return partialview("_partialview1"); //this view should exist in appropriate views folder.     } 

b. buttons on left handside should @ajax.actionlink

@ajax.actionlink(     "button1",     "getpartialview1",     new {          value1 = 1},     new ajaxoptions     {         httpmethod = "get",         insertionmode = insertionmode.replace,         updatetargetid = "righthandsidebox"     }     ) 

c. updatetargetid = "righthandsidebox" should id of div on right hand side. contents of righthandsidebox replace partialview


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -