How to populate textbox value real time upon date start and end entry on a razor view?
Q: How can I populate a text box value (number of days) realtime based on a 开发者_如何学Pythonuser entering start and stop dates within an mvc3/razor view? Thx!
Either you would onblur, postback with Ajax and use server logic to fill the textbox value with number of days. Or, ideally, you would use jquery to do this so it is most responsive and realtime.
$("#textbox1, #textbox2").change(function()
{
$.ajax(
{url: '/controller/action',
data: { date1: $("#textbox1").val(),date2: ("#textbox1").val()},
success: function(data){
$("#days_textbox").val(data);
}})
});
精彩评论