VS2013 기준
TOOLS > NuGet PakageManager > Manage NuGet Pakages for Solution... > Installed pakages 에서 "Miscrosoft jQuery Unobtrusive Ajax " 설치 유무 확인하세요. 없으면 Online 탭에서 검색 후 설치하세요.
BundleConfig.cs
@Scripts.Render("~/bundles/jqueryval")
구문 Index.cshtml 에 추가
Index.cshtml
AssignDataList.cshtml
BundleConfig.cs
public class BundleConfig { // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( "~/Scripts/bootstrap.js", "~/Scripts/respond.js")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/site.css")); } }BundleConfig.cs 에서 jqueryval 에 넣었으면
@Scripts.Render("~/bundles/jqueryval")
구문 Index.cshtml 에 추가
Index.cshtml
@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryval") @using (Ajax.BeginForm("GetList", "Master", FormMethod.Post, new AjaxOptions { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = "dataGrid" }, new { id = "search_form" })) { <input type="hidden" name="page" value="1"> <!-- 첨삭 센터 선택 시작--> <div class="panel panel-default"> <div class="panel-body"> <div class="form-group-sm"> <label for="SchoolSelect" class="col-lg-2 control-label hidden">선택</label> <div class="col-lg-10"> <select class="form-control input-group-sm" id="SchoolSelect"> <option value="" selected="selected">첨삭센터를 선택하세요.</option> <option value="1">1</option> </select> <button class="btn btn-default" type="submit">검색(ajax)</button> </div> </div> </div> </div> } <hr> <div class="form-group-sm" id="dataGrid"> @Html.Partial("AssignDataList") </div>PartialView 인
AssignDataList.cshtml
@{ Layout = null; } @{ if (Model != null) { var grid = new WebGrid( canPage: true, rowsPerPage: Model.PageSize, canSort: true, ajaxUpdateContainerId: "grid"); grid.Bind(Model.Content, rowCount: Model.TotalRecords, autoSortAndPage: false); grid.Pager(mode: WebGridPagerModes.All , firstText: "처음" //,previousText : "이전" //,nextText : "다음" , lastText: "마지막" , numericLinksCount: 5 ); grid.GetHtml(htmlAttributes: new { id = "grid" }, // id for ajaxUpdateContainerId parameter fillEmptyRows: false, tableStyle: "table table-striped table-hover ", headerStyle: "webgrid-header", footerStyle: "webgrid-footer", alternatingRowStyle: "webgrid-alternating-row", selectedRowStyle: "webgrid-selected-row", rowStyle: "webgrid-row-style", //mode: WebGridPagerModes.All, columns: grid.Columns( grid.Column(header: "선택", format: @<text><input type="checkbox" name="cbSelectbox" value=""></text>), grid.Column("SchoolCode", "학원코드"), grid.Column("School", "학원"), grid.Column("BR", "BR"), grid.Column("WR", "WR") ) ); } }
'Web_Application > ASP.NET MVC' 카테고리의 다른 글
Error 1053: "The service did not respond in a timely fashion" when attempting to start, stop or pause a service (0) | 2016.12.29 |
---|---|
Upgrading mvc4 to mvc5 in vs2013 (0) | 2016.12.17 |
JSON JavaScriptSerializer를 사용하여 serialize 또는 deserialize하는 동안 오류가 발생했습니다. 문자열의 길이가 maxJsonLength 속성에 설정된 값을 초과합니다. (0) | 2016.10.10 |
CORS 해결방법 (0) | 2015.12.10 |
[ASP.NET MVC] 도로명주소 검색하기 소스 (0) | 2015.03.13 |