Я пытаюсь запустить новую страницу предварительного просмотра, для этого я пытаюсь позвонить, когда мы нажимаем на изображение. А также мне нужно передать идентификатор в качестве параметра на новую страницу. & Я хочу получить его в public ActionResult Index
методе public ActionResult Index
. Вот код, который я пробовал.
От родителей index.aspx
<a href="#" onclick="openWindow('Preview/Index.aspx?ID = 12344');"><img style="border:0;" src="/Content/Images/approveIcon.png" alt="HTML try" width="20" height="20" /></a>
<script language='Javascript'>
<!--
// Function to open new window containing window_src, 100x400
function openWindow(window_src) {
window.open(window_src, 'newwindow', config = 'height=100, width=400, '
+ 'toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, '
+ 'directories=no, status=no');
}
-->
</script>
Вот мой новый класс контроллера предварительного просмотра
public class PreviewController : Controller
{
//
// GET: /Preview/
public ActionResult Index(String ID)
{
return View();
}
}
Я получаю недостающую информацию о ресурсе, Как запустить новое окно предварительного просмотра и передать идентификатор в качестве параметра для индекса?
function openWindow(srcid) {
$.ajax({
url: 'Preview/Index',
type: "POST",
dataType: "json",
data: { ID: 12344},
success: function (data) {
alert(error.toString());
},
error: function (error) {
alert(error.toString());
}
});
}
<a href="#" onclick="openWindow();"><img style="border:0;" src="/Content/Images/approveIcon.png" alt="HTML try" width="20" height="20" /></a>
Надеюсь, это поможет: в вашей ссылке
<a href="#" onclick="openWindow(@Url.Action("Index", "Preview", new { id = "1234" });"><img style="border:0;" src="/Content/Images/approveIcon.png" alt="HTML try" width="20" height="20" /></a>
И в вашем скрипте
<script language='Javascript'>
<!--
// Function to open new window containing window_src, 100x400
function openWindow(window_src) {
var path = window.location.pathname + window_src;
alert(path);//So you can see the full path
window.open(path , 'newwindow', config = 'height=100, width=400, '
+ 'toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, '
+ 'directories=no, status=no');
}
-->