I try to post textbox value to actionresult in asp.net mvc
Javascript:
function OnButtonClick() {
var data= {
TextBox: TextBox.GetValue()
};
var PostData= data.TextBox;
window.location.href = "Home/MyActionResult?Page=data" + PostData;
}
ActionResult
public ActionResult MyActionResult(string PostData)
{
return view();
}
Whenever I post data to Home/MyACtionResult
, PostData is always null
,
What am I missing ?
How can I post textbox value to actionresult?
Try with this:
window.location.href = "Home/MyActionResult?Page=data&PostData=" + PostData;
Try this
var url = '@Url.Action("../Home/MyActionResult")' + '?Page='+data+'&'+PostData;
window.location.href = url;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With