Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<div style="padding:5px;">
                   <button value="Textbox" name="button" id="1" style="width:120px;background-color:lightgreen;">Textbox</button>

               </div>
               <div style="padding:5px;">
                   <button value="Chekbox" name="button" style="width:120px;background-color:lightgreen;">CheckBox</button>
               </div>
               <div style="padding:5px;">
                   <button value="Radio" name="button" style="width:120px;background-color:lightgreen;">Radio</button>
               </div>


I have three button in view, Onbutton click add dynamic controls using mvc 4 razor,
If anybody know please help me.

Thanks in advance
Posted

You can do it by using a Javascript associated with the button OnClientClick event that should invoke via AJAX a method from your Controller that have to create a partial view for your dynamic controls that you want to add.

For details about using Javascript, AJAX and PartialView in ASP.NET MVC application you should view the next short tutorial video: AJAX and Javascript in ASP.NET MVC[^]
 
Share this answer
 
v2
thankx,
can i fetch id of dynamic controls using javascript???
 
Share this answer
 
Comments
Raul Iloc 10-Feb-15 6:06am    
1. You should post your questions/comments under my solution and not as a new solution.

2.Regarding your question, you could dynamically add also associated Javascript directly in the new added code (or partial view).
Mukesh Patil 13-Feb-15 0:21am    
ok and Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900