Tag: asp.net mvc

需要添加哪些jQuery引用才能使Bootstrap正常工作,在哪里?

我一直在努力与bootstrap和自定义CSS不共存(见此) 我看到我得到了“Uncaught Error:Bootstrap的JavaScript需要jQuery”,因此,基于我在这里找到的(Sridhar接受的答案),我改变了这个: builder.Append(“”); builder.Append(“”); builder.Append(“”); ……到此为止: builder.Append(“”); builder.Append(“”); builder.Append(“”); ……但没有区别。 我需要做些什么来让Bootstrap实现我引用jQuery? UPDATE 我将引号从double更改为single并删除了后备,因此jquery引用现在是这样的: builder.Append(“”); ……但没有区别。 更新2 即使我添加这样的内联样式: builder.Append(“”); ……它不会改变wimpy(几乎不可见)的横向规则。

ObjectContext实例已被释放,不能再用于需要连接错误级联下拉列表的操作

我尝试在MVC4中级联下拉列表。 我有2个下拉列表1 – 类别2 – 子类别。 当用户创建新产品时,他需要选择Category,然后选择与该类别相关的SubCategory。 我和杰森一起使用ajax。 public ActionResult Create() { List allcategories = new List(); List allSubCategories = new List(); using (WebStoreEntities1 db1 = new WebStoreEntities1()) { allcategories = db1.Categories.OrderBy(x => x.CategoryName).ToList(); } ViewBag.categoryID = new SelectList(db.Categories, “CategoryId”, “CategoryName”); ViewBag.SubCategoryID = new SelectList(allSubCategories, “SubCategoryId”, “SubCategoryName”); return View(main); } 在html页面中的Jquery代码: $(document).ready(function () { var […]

JS从文本框中抓取文本,传递给asp.net mvc ActionResult,但ActionResult参数显示为null

JS从文本框中抓取文本,传递给asp.net mvc ActionResult,但ActionResult参数显示为null 我有2个文本框,在用户选择时由2个日期选择器填充,但是当我使用下面的javascript将其传递给actionresult时,信息正确地从文本框中获取。 actionresult的参数显示为null。 我该如何解决? 码: @Html.Label(“Start”, “Start Date:”) @Html.TextBox(“Start”, string.Empty, new {@id = “Start”, @class = “datepicker”}) @Html.Label(“endd”, “End Date:”) @Html.TextBox(“endd”, string.Empty, new {@id = “End”, @class = “datepicker”}) $(‘.datepicker’).datepicker(); $(“#DateSelected”).click(function () { var startD = $(‘#Start’).val().toString(); var endD = $(‘#End’).val().toString(); $.ajax({ url: ‘/Docs/FirstDoc’, type: “Post”, data: { start: String.valueOf(startD), end: String.valueOf(endD) }, […]

JQGrid没有显示json数据

我已经努力了,但我没有取得任何成功。 我的控制器是 public ActionResult CompOff() { return View(); } [HttpPost] public JsonResult CompOff(RegisterCompOff r) { var compoffs = db.RegisterCompOffs.Where(l => l.Employee.Id == this.EmployeeId).Select(l => new { l.CompOffDate, l.Description, l.ExpiryDate, l.IsApproved, l.IsUtilized }).ToList(); return Json(compoffs); } 我的观点是 $(document).ready(function () { $(‘#jqgProducts’).jqGrid({ //url from wich data should be requested url: ‘@Url.Action(“CompOff”)’, //type of data datatype: ‘json’, //url […]

如何根据MVC中的下拉选择设置validation?

这是我的查看代码: @Html.LabelFor(model => model.device.HasAMC, htmlAttributes: new { @class = “control-label col-lg-4” }) @Html.EditorFor(model => model.device.HasAMC, new { htmlAttributes = new { @class = “form-control” } }) @Html.LabelFor(model => model.device.AMCExpiredDate, htmlAttributes: new { @class = “control-label col-lg-4” }) @Html.EditorFor(model => model.device.AMCExpiredDate, new { htmlAttributes = new { @class = “form-control”, placeholder = “AMCExpireDate(MM/dd/yyyy)”, required = “required”, […]

如何将serializeArray作为json传递给MVC控制器

我有一个表单,我想将数据传递给我的控制器。 这是我正在制作的JQuery调用 – var data = $form.serializeArray(); var options = { contentType: “application/json”, url: “/Form/Save”, data: JSON.stringify(data), type: “post”, datatype: “html”, success: function (result, xhr, status) { console.log(result); }, error: function (xhr, status, error) { // redirect to error page } }; $.ajax(options); 这就是我在控制器中接收它的方式 – public ActionResult Save(string paramJson) { // save paramJson return null; […]

成功后提交show welcome-modal

我有表格 @using (Html.BeginForm(“Register”, “Account”, FormMethod.Post, new {id = “registrationForm”})) {…} 我把一些数据(电子邮件,密码等)放在哪里 我也有这种forms的方法: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Register(RegisterViewModel model) {… return RedirectToAction(“Index”);} 在那种方法中,我管理模型(尝试创建新用户),如果一切都成功。 重定向到行动“索引”。 问题 :我需要在创建新用户之后但在重定向之前显示带有一些文本“Welcome …”的bootstrap模式。 我该怎么做? 我尝试为该表单调用ajax submit(仅用于显示该模式的成功操作,但没有成功)

在asp.net mvc中使用jquery ajax提交post后更新部分视图

我在我的应用程序中处理一个表单,我想使用ajax发布。 发布工作正常,我的控制器收到数据,但我想将成功消息发回我的视图,而不是刷新整个页面。 我是否必须返回包含此信息的部分视图,或者我可以从控制器返回消息? 我似乎无法弄清楚如何正确地做到这一点。 @Html.LabelFor(m => m.Id, new { @class = “col-md-3 control-label”}) @Html.TextBoxFor(m => m.Id, new { @class = “form-control”, disabled = “disabled”, id = “WellId”, name = “WellId” }) @Html.LabelFor(m => m.Name, new { @class = “col-md-3 control-label” }) @Html.TextBoxFor(m => m.Name, new { @class = “form-control” }) @Html.LabelFor(m => m.Location, new { […]

jqGrid结果流过网格和“请,选择行”消息

(我对网络编程比较陌生,所以它可能是一个容易被忽视的问题) 我正在使用ASP.NET MVC4来构建一个包含显示jqGrid的剃刀视图的应用程序。 它使用ajax动态获取列元数据,并且所有数据似乎都返回正常。 当我运行应用程序并显示视图时,会显示数据,但网格的标题和正文都会在网格上流动(请参见图像)。 我注意到数据下面似乎有一条警告,上面写着“请选择行”。 我的怀疑是问题是CSS还是与警告有关。 我试过更改ui.jqgrid.css,site.css等中的各种属性无济于事。 这是渲染的html: Feed List Preview var jqDataUrl = “LoadData”; var jqMetaUrl = “GetColumnData”; $(document).ready(function () { $.ajax( { type: “POST”, url: jqMetaUrl, data: “”, dataType: “json”, success: function (result) { col_names = result.colNames; col_model = result.colModel; $(“#jqTable”).jqGrid({ url: jqDataUrl, datatype: “json”, mtype: “POST”, //Specify the column names colNames: […]

如何使用JSONP将复杂数组发送到asp.net mvc控制器

我如何使用JSONP 发送复杂类型对象与其中的数组 var product= {categories:[ {id:1,text:”cat 1″},{id:2,text:”cat 2″}],id:43,price:3535}; $.getJSON(url ,product, function (data) { //i can get the data from the server but i cant pass the complex array to the server }); 并在asp.net mvc服务器上: public JsonpResult Create(Product product) { string thisisok = product.id; string needthis = product.categories[0].text; return new JsonpResult { Data = true }; […]