1
我是新來asp.net的MVC插入模式對話框4.如何從表單中檢索值,並使用asp.net mvc4
我有一個包含一個形成一個文本框和一個預覽按鈕(如果我將點擊預覽按鈕,然後打開一個模式框,模式框中有一個文本框)。運行應用程序後,我必須將值插入到文本框中,之後當我點擊預覽按鈕時,文本框值應顯示在模態框文本框中。
編碼 index.cshtml
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<button id="modal-opener">preview</button>
<input type="text" name="username" />
<input type="text" name="pasw" />
<div id="dialog-modal" title=" Basic Modal Dialog">
<p>This is test</p>
<input type="text" name="username" />
</div>
Homecontroller.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace ModalPopUp.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")
<link href="~/content/themes/base/jquery-ui.css" rel="stylesheet" />
@Scripts.Render("~/bundles/jquery")
<script src="~/scripts/jquery-ui-1.8.24.min.js"></script>
@Scripts.Render("~/bundles/modernizr")
<script>
$(function() {
$("#dialog-modal").dialog({
autoOpen: false,
height: 300,
width: 300,
modal:true,
show:{
duration:100
},
hide: {
duration: 1000
}
});
$("#modal-opener").click(function() {
$("#dialog-modal").dialog("open");
});
});
</script>
</head>
<body>
@RenderBody()
@RenderSection("scripts", required: false)
</body>
</html>
任何人都可以幫我解決這個問題嗎?我會插入應該顯示在模式框的文本框中的文本框的值?
非常感謝你這是工作的罰款.... – Binay 2014-09-05 12:06:46
你能告訴我一兩件事,如果我有<標籤ID =「用戶名」>然後我怎麼能在jQuery的訪問? – Binay 2014-09-05 12:27:50
@Cool,使用'#'在通過ID $'(「#username」)訪問元素時使用'#' – 2014-09-05 13:11:24