Javascript 提交表单时打开包含该表单所有值的modeldialog
我有一个MVC4.0网站,在屏幕上有一个按钮。根据我的要求,我已经提交了一个隐藏的形式,有一些隐藏的价值观,点击该按钮。我的要求是 我必须打开一个包含所有这些隐藏值的模型对话框 请给我一些解决办法Javascript 提交表单时打开包含该表单所有值的modeldialog,javascript,html,asp.net-mvc-4,Javascript,Html,Asp.net Mvc 4,我有一个MVC4.0网站,在屏幕上有一个按钮。根据我的要求,我已经提交了一个隐藏的形式,有一些隐藏的价值观,点击该按钮。我的要求是 我必须打开一个包含所有这些隐藏值的模型对话框 请给我一些解决办法 //under a Beginform of a view this button code is written <input type="button" id="idBtnScan" name="btnName" value="Scan" onclick="javascript:subPr
//under a Beginform of a view this button code is written
<input type="button" id="idBtnScan" name="btnName" value="Scan" onclick="javascript:subProcessURL()" />
//I have add this hidden form on click of this button
//@Model.UDConfig.sScanningURL = is the url of the another website's default page
//Model.UDConfig.listScanData (list) that contains all parameter that takes another website.
<form id="idFormSelect" action ="@Model.UDConfig.sScanningURL" method="post" >
<div class="makeHidden">
@for(int i=0;i<Model.UDConfig.listScanData.Count;i++)
{
<input type="text" id="@Model.UDConfig.listScanData[i].sKey" name="@Model.UDConfig.listScanData[i].sKey" value ="@Model.UDConfig.listScanData[i].sValue" />
}
<input type="text" id="ASPUserSessionId" name="ASPUserSessionId" value="@Session.SessionID" />
<input type="submit" name="SubmitDetails" />
</div>
</form>
<script type ="text/javascript" >
function subProcessID() {
window.showModalDialog("@Model.UDConfig.sScanningURL", "#idFormSelect", "dialogWidth:700px;dialogHeight:500px;scroll:no;")
$("#idFormSelect").submit();
}
</script>
$("#idBtnScan")[0].onclick = function () {
HideDivInfoNErrorMsg();
ShowOverlay_Base();
subProcessURL();
@*$.ajax({
//type: "POST",
//url: "@Url.Action("GetSingleScanURL", "CreationOutward")",
//success: function (data) {
//window.showModalDialog(data, "", "dialogWidth:700px;dialogHeight:500px;scroll:no;")*@
//functionality of view image
$.ajax({
type: "POST",
url: "@Url.Action("ActionViewImage", "CreationOutward")",
success: function (dataImage) {
HideDivInfoNErrorMsg();
if ((dataImage == "Image not found")
|| (dataImage == "Image Folder not found")
|| (dataImage == "Error in processing image")
|| (dataImage == "Multiple Images found")) {
$("#DivInfoNErrorMsg")[0].innerHTML = "<div class=\"errormessage\"><span>".concat(dataImage, "</span></div>");
DisplayInfoNErrorMsg();
}
else {
$("#divImgView")[0].innerHTML = dataImage;
HideDivInfoNErrorMsg();
}
HideOverlay_Base();
}
})
//View Image till here
//}
//}
// )
}
//此按钮代码是在视图的通知下编写的
//我已经添加了这个隐藏的形式点击这个按钮
//@Model.UDConfig.sScanningURL=是另一个网站的默认页面的url
//Model.UDConfig.listScanData(列表),其中包含获取其他网站的所有参数。
@为了(int i=0;i您的按钮调用一个名为“subProcessURL”的javascript函数,但在您的代码中只有一个subProcessID函数。这些函数不匹配到目前为止您有什么?向我们展示一些代码…我添加了一段代码供您参考。对于任何查询,请询问我。感谢您的回复。感谢您的回复,但在做出更改之后问题仍然是一样的。那么“问题”到底是什么?如果调用subProcessID,对话框将显示,一旦关闭,表单将提交…实际上,当我单击按钮时,屏幕上没有任何事情发生。单击按钮后,没有模型对话框窗口打开。您提供的代码似乎很好,除了函数名没有不匹配。这里有一个可用的fiddle:jsfiddle.net/AnqXx。我没有sScanningURL属性,但您知道,当您单击“扫描”按钮时,模式仍然会打开……在做了一些更改后,我发现另一个关键点工作正常。实际上,我发现在代码中有一个ajax函数,在单击按钮。正因为如此,我的java脚本函数没有在单击按钮时调用。现在,我已将函数调用放在该ajax函数中。现在,另一个窗口可以通过url正常打开。现在,我的问题是,所有表单值都没有传递到单击按钮时提交的窗口控件。