Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In mvc we bind a view using strongly typed model. Is there a way to get the current model value and make some change and refresh the view with same model without refreshing the content( images etc.). ie without having a complete postback just the controls needs to be refreshed.
I know about partial view.


The actual scenario in which iam currently is i have a drop down products. next to that there is a link to create a new product which is a popup form. After creating a product i have to refresh the drop down. i could use jquery to bind data using json. But iam using a strongly typed view. I wont be able to get the complete model(inc product id select from dropdown, will have to write assigning code for drop down selection ).
Using a partial view and placing just a drop down in it seems bad too....
Posted
Updated 6-Jul-14 6:25am
v2
Comments
[no name] 6-Jul-14 12:37pm    
You can do it in jquery and submit data from your partial view

1 solution

Please learn about Ajax: http://en.wikipedia.org/wiki/Ajax_(programming)[^].

See also: http://msdn.microsoft.com/en-us/library/dd381533%28v=vs.100%29.aspx[^].

This CodeProject article can also be useful: JQuery AJAX with ASP.NET MVC[^].

—SA
 
Share this answer
 
Comments
Praveen Kumar U 6-Jul-14 12:59pm    
But i have binded like this
@Html.DropDownListFor(model => model.MobjBill.Customerid,new SelectList(Model.Custlist,"Text","Value",Model.MobjBill.Customerid))

model => model.MobjBill.Customerid..This assignment wont work.
Praveen Kumar U 6-Jul-14 13:03pm    
Ok....i could append an option intead
$("#ddlProducts").append($("<option></option>").val("10").html("abc"));

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