Tag: c#

Pagnation没有更新目标 – 使用Ajax的Asp.Net Core

我希望这是直截了当的! 我有一个部分加载很好,它使用ajax应用filter/排序工作正常。 然而,分页链接发送正确的URL,响应是所需的页面,只是它实际上没有更新/替换那里的什么。 父视图: @model Sakura.AspNetCore.IPagedList @{ ViewBag.Title = “Review Dashboard”; @using YaCu_2017.Controllers; } @ViewBag.StatusMessage @ViewBag.ErrorMessage Our Product Reviews Filter by Product: @{ var product = ReviewController.GetProductListIncId(); var productCount = ReviewController.GetProductCountList(); ViewBag.ProductList = product; ViewBag.ProductCount = productCount; } Reviews per page @await Html.PartialAsync(“ShowReviewDetails”, Model) 儿童视图: @model IPagedList @using System.Globalization @using Sakura.AspNetCore @using YaCu_2017.Controllers @using YaCu_2017.Models […]

如何在JSONP响应中管理?

我需要管理像’在我的JSONP请求中的char,通过jquery进行Ajax。 所以(来自C#)这就是我所做的: myText = “Hello I’m a string”; myText.Replace(“‘”, “\'”); Response.Write(Request[“callback”] + “({ htmlModulo: ‘” + myText + “‘});”); 但在客户端,它破了: parsererror – SyntaxError: missing } after property list 所以,我如何管理’如果替换不起作用?

Selenium – 将“WebElement”转换为Javascript或JQuery对象的通用方法

我有一个简单的WebElement,我想在我的对象上执行一系列(一个或多个)JS / JQuery类型的操作。 大多数情况下这很简单,我只需获取对象的ID,将其传递到“ExecuteScript”函数中,并且中提琴效果很好: RemoteWebDriver driver = …; var element = driver.FindElementByXPath(“…”); //Or any other type of lookup driver.ExecuteScript(@”$(‘#” + element.GetAttribute(“id”) + “‘).”DoSomeStuff…;”); 20%这根本不起作用,因为该项目没有ID。 当然,有许多方法可以在Selenium中查找项目以及在jQuery或Javascript中查找项目的许多方法,但它们并不总是映射,虽然可以在jQuery中构造一个可以查找Selenium对象的查询,方法对于每种对象类型都不一样。 搜索它似乎大多数人使用“id”方法(例如: 1,2,3 )。 你可以用相反的方式做到这一点 。 另一个想法是在jQuery中访问它之前给每个元素在selenium中提供一个唯一的ID,但它看起来不会起作用,因为设置它需要使用Javascript或jQuery。 我还没有找到一种方法来为每个元素做这个普遍的事情,如何做到这一点?

单击按钮时,在视图中添加列表框中的项目

我有这个模型 public class CreateAppointmentSelectPersons { [DataType(DataType.EmailAddress, ErrorMessageResourceType = typeof (Resource), ErrorMessageResourceName = “CreateAppointment_Email_Invalid_Email_Address”)] [EmailAddress] [Display(ResourceType = typeof(Resource), Name = “RegisterViewModel_EmailId_Email_Id”)] public string Email { get; set; } public Boolean IsSuperOfficeConnected { get; set; } [Display(ResourceType = typeof (Resource), Name = “CreateAppointmentSelectPersons_SelectedSuperOfficeEmail_SuperOffice_Contact”)] public string SelectedSuperOfficeEmail { get; set; } public Boolean IsInternalAddressBookEmpty { get; set; } […]

Jquery自动完成.NET WebMethod

我使用HttpHandler – .ashx文件进行Jquery自动完成。 它工作正常,我想知道是否有一种简单的方法在后面的代码中使用[WebMethod]权限自动完成 – 这有什么优势吗?

如何设置.asmx webservice使用Asp.net启用跨域

我的网络服务代码是 [WebMethod] public List GetMachineData_List(string prefix, int person_id) { using (var db = new TestDB()) { List list = db.Fetch(“select id,name from machine_data_collection mc where mc.id=@0 and name like ‘%” + prefix + “%'”, person_id); return list.ToList(); } } 我的jquery Ajax调用是 $(“#textbx”).autocomplete( { source: function (request, response) { $.ajax({ url: ‘http://localhost:4787/ws/webservice.asmx/GetMachineData_List’, data: { prefix: request.term.toString() […]

inheritance/覆盖来自不同外部文件的现有CSS规则

我有一个现有的项目,曾经没有Bootstrap(3),但现在我必须改变它并保留旧的CSS。 我目前的CSS订单: var bundleCSS = new StyleBundle(“~/Views/bundle/newBundle”).Include( “~/Views/Shared/normalize.css”, “~/Scripts/jquery.ui/jquery-ui-latest.custom.css”, “~/Scripts/jquery.jqGrid/ui.jqgrid.css”, “~/Scripts/sweetalert/sweet-alert.css”, “~/Content/bootstrap.css”, “~/Views/Shared/OldButNeededLayout.css”, “~/Content/custom.css”); //will be rendered in that order custom.css用于修复将bootstrap.css添加到项目中的所有错误。 这里的问题是, OldButNeededLayout.css有OldButNeededLayout.css 3000行的css-code,顺便提一下当前的项目非常大。 因此,当用旧css覆盖引导程序而不是通过添加引导程序来修复错误时,我得到的结果不可预测。(因为我不知道它会改变什么) 怎么做或如何解决将bootstrap css / js集成到(我的)现有项目中的问题?

通过在ASP.Net MVC 5中使用DataTables行重新排序来更新值

我需要通过datatables( www.datatables.net )中的row-reorder函数更新数据库中的OrderIndex值。 我已经在谷歌搜索过,我发现了这篇文章 。 我遵循了所有步骤,但没有帮助。 如果您需要更多信息,请与我们联系。 谢谢 视图模型 public class GenderDDUpdateOrderIndexViewModel { public int Id { get; set; } public int OrderIndex { get; set; } } 调节器 public async Task UpdateRowIndex(GenderDDUpdateOrderIndexViewModel model, int? Id, int? fromPosition, int toPosition, string direction) { using (var ctx = new ApplicationIdentityDbContext()) { if (direction == “back”) { […]

webforms:在javascript选项中动态添加到下拉列表中

我正在开发一个asp.net webforms应用程序。 我的页面由2个下拉列表组成。 在ddl1上的每个选择中,我想通过javascript动态地将ddl1的所选元素添加到ddl2。 默认情况下,首次加载页面时,ddl1由3个元素(a,b,c)组成,ddl2仅由一个元素(a)组成。 function ddl1_handler() { var ddl2 = document.getElementById(“ddl2”); var newOption = document.createElement(“option”); newOption.text = document.getElementById(“ddl1”).value; newOption.value = document.getElementById(“ddl1”).value; ddl2.add(option); } 这是我的code_behind代码: private List choices = new List() { “a”, “b”, “c”}; protected override void Render(HtmlTextWriter writer) { foreach (var choice in choices) { Page.ClientScript.RegisterForEventValidation(ddl2.UniqueID, choice); } base.Render(writer); } protected void Page_Load(object […]

从后面的代码添加用户控件

我的页面上有一个用户控件( UserControl1 )和一个Add more按钮。单击Add More按钮再次添加相同的用户控件。当我第一次点击用户控件时,它会添加第二个User Control,但是第二次它没有添加其他。我认为控件丢失了。 我在链接按钮点击上添加这样的控件: – protected void lnkadd_Click(object sender, EventArgs e) { HtmlTableCell tCell = new HtmlTableCell(); UserControl uc = (UserControl)Page.LoadControl(“~/Controls/DirectionalPricingCtrl.ascx”); tCell.Controls.Add(uc); tablerow.Cells.Add(tCell); } 我想我做错了什么,我应该在页面生命周期中添加用户控件,但是如何? 有人可以指导我或提供一些有用的链接吗? 当我每次单击“添加”按钮然后检索所有值并将其保存到DB时,我必须添加用户控件时应该遵循什么方法?