Click here to Skip to main content
14,928,868 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am doing the development for a payment screen in ASP.NET MVC (Razor engine), When the selection is changed, it should populate different partial view, it's not working, here is my code in a view file:
Can someone take a look?



<label class="control-label p1-control-label col-md-6 pull-left">Auto Draft/Credit Card</label>

@Html.DropDownList("paymentMethod", new SelectList(new List&<object>{
new { value = 0 , text = "Bank Draft" },
new { value = 1 , text = "Credit Card" },
new { value = 2 , text = "None" }},
"value",
"text",
0), new { @class = "form-control", id ="ddpaymentMethod" } )






@Html.Partial("_BankDraft")





Here is script:

$('#ddpaymentMethod').change(function () {
alert("I am clinking the drop-box");
var url = "/Payment/ChangePaymentMethod";
$.get(url, function (data) {
$("#paymentMethodArea").html("");
$("#paymentMethodArea").html(data);
$("#paymentMethodArea").fadeIn('fast')
});
});

Here is in control:
public ActionResult ChangePaymentMethod()
{
return PartialView("_CreditCard");
}
Posted

1 solution

need to apply onchange method with 'paymentMethod'object name
   

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