Ambient form data in ASP.NET MVC -
i came across problem ambient form data, i've tried isolate following example.
view model:
public class viewmodel { public int value { get; set; } }
controller:
public class testcontroller { public viewresult test1() { return(view(new viewmodel {value = 1})); } [httppost] public viewresult test2(viewmodel vm) { vm.value = 2; return(view(vm)); } }
test 1 view:
@model viewmodel @using(html.beginform("test2", "test")) { @html.textboxfor(m => m.value) <button type="submit">send</button> }
test 2 view:
@model viewmodel @model.value @html.textboxfor(m => m.value)
submitting form in view 1 gives the, @ least me, surprising result in view 2:
seems posted value gets used in textboxfor(). knows what's going on here , how avoid it?
Comments
Post a Comment