http post - ASP.NET MVC show result without refreshing page -
i did currency converter. have problem. when click calculate page refreshing , datas entered user cleaning. think because of using return view();
:) .how can solve problem? thanks
{ viewbag.result = frmamount; } return view();
view
</p> <p> <label for="text3">amount:</label> <input type="text" name="frmamount" /> </p> <p> <input type="submit" value="calculate" /> </p> <p> <label for="text3">sonuç:@viewbag.result</label> </p>
for example amount wiped when button clicked
the amount data cleaning because when click on calculate button returning same view again. in order keep amount data should pass amount value view viewbag (viewbag.amount
) or passing object model view using second parameter of view(viewname, model)
.
in general, recommend try avoid using viewbag variables. preffered method use viewmodel instead due e.g. refactoring. can read more here: click!
Comments
Post a Comment