I have a javascript function that calls a MVC action result which in turn will populate the correct View. I need to pass .Net code with that pop up call, is it possible?
So for example I need to pass a integer from the model over so I can use it in my action result.
a button click calls this function
ShowPopUp = function () {
window.showModalDialog("/FileUpload/GetPopupData", "wndPopUp", "width=300,height=500");
}
and here is the action result
public ActionResult GetPopupData()
{
//Call the pop up view and populate it accordingly
return new GetDocumentTypeAction<ActionResult>
{
OnLoaded = m => View("../../Areas/Exports/Views/FileUpload/FileUpload", m),
OnErrorOccured = (m) => Redirects.ToErrorPage()
}.Execute(GtsClient);
}
How will I send the int over and how will I read it in the action result?
In your view, render out the integer you want from the model as a JavaScript variable that you can reference in your ShowPopUp() function.
<script>
var viewId = <%=Model.ViewId%>;
ShowPopUp = function () {
window.showModalDialog("/FileUpload/GetPopupData/" + viewId,
"wndPopUp", "width=300,height=500");
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.