Tag: asp.net

C#UserControl上的Jquery .ajax异步回发

我正在努力向项目系统添加待办事项列表,并希望todo创建触发异步回发以更新数据库。 我真的想在一个用户控件中托管这个,所以我可以将todo列表放到项目页面,任务页面或独立的待办事项列表页面上。 这就是我所拥有的。 用户控件“TodoList.ascx”,它位于Controls目录中。 位于UserControl顶部的脚本。 你可以看到我开始构建jsonText到回发的位置,但是当它不起作用时我只是尝试回发一个空数据变量并从AddTodo2方法中删除’string [] items’变量。 $(document).ready(function() { // Add the page method call as an onclick handler for the div. $(“#divAddButton”).click(function() { var jsonText = JSON.stringify({ tdlId: 1, description: “test test test” }); //data: jsonText, $.ajax({ type: “POST”, url: “TodoList.aspx/AddTodo2”, data: “{}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { alert(‘retrieved’); $(“#divAddButton”).text(msg.d); […]

asp.net从静态函数访问控件

我有一个webform,在那个webform中,我试图从静态方法访问Panel对象,但无法访问它如何从静态方法访问Panel对象。 为什么我要尝试从静态访问对象? 因为我使用的JQUERY只接受静态方法。 我试图在Page_Load()中将Panel存储在会话中并从静态方法中检索它但它不起作用。

ASP.NET MVC3:ValidationType ModelClientValidationRule

我刚刚创建了一个示例MVC3应用程序来学习validation。 它正在使用DataAnnotations。 我创建了一个名为CustomStartLetterMatch的自定义ValidationAttribute 。 它正在实现“System.Web.Mvc.IClientValidatable”。 我有相应的客户端代码用不引人注目的jQuery编写。 这是按预期工作的。 关于自定义validation器:它比较第一个名称输入和姓氏输入。 如果它们的第一个字符不相同,则抛出错误。 正如我所说,该应用程序运行正常。 但是当我查看规则时rule.ValidationType = “greaterdate”; 我很困惑。 我想把它改成像“anotherDefaultType”这样的东西。 当我更改它时,它失败并出现jQuery错误。 这是什么原因? 有哪些可用的ValidationTypes? 在此场景中更改ValidationType的建议方法是什么? 码: using System; using System.ComponentModel.DataAnnotations; using System.Collections.Generic; namespace MyValidationTEST { public class Person { [Required(ErrorMessage = “First name required”)] public string FirstName { get; set; } [CustomStartLetterMatch(“FirstName”)] [StringLength(5,ErrorMessage = “Must be under 5 characters”)] public string […]

在asp:按钮上的jQuery Click事件

我有一个服务器端按钮 我想使用其ID附加jQuery Click事件,而不是使用替代类属性方式。 我试图将click事件附加为: $(“#btnSummary”).click(function() { alert(“1”); }); 但是,它的click事件不会被触发。 另外,我也试过$(“id[$btnSummary]”) 。 有没有办法在没有按钮上的class属性的情况下使用jQuery在asp:button上附加click事件?

如何从asp.net按钮单击事件调用javascript函数

如何从asp.net按钮单击事件中调用showDialog。 我的页面是一个内容页面,其中包含与之关联的母版页。 我尝试了以下内容 <asp:Button ID="ButtonAdd" runat="server" Text="Add" OnClientClick="showDialog(#);” /> 我还必须从gridview模板按钮调用此相同的函数来修改对话框中的记录。 // Used the following example to open the dialog withJquery var dl; $(document).ready(function () { //Adding the event of opening the dialog from the asp.net add button. //setup edit person dialog $(‘#addPerson’).dialog({ //Setting up the dialog properties. show: “blind”, hide: “fold”, resizable: false, modal: true, […]

对Json的回应感到沮丧

所以这是我的问题。 我正在使用Jquery的$ .ajax将一系列值传回Web方法。 Web方法获取值,创建一个对象,然后将其作为json发送回调用页面。 一旦我收到回复,我就无法访问响应并显示它的值。 任何人都可以解释我需要做些什么来使这项工作? jquery脚本: $(document).ready(function() { $(“#create”).click(function() { var name = $(‘#name’).val(); var company = $(‘#company’).val(); var location = $(‘#location’).val(); var phonenumber = $(‘#phonenumber’).val(); var country = $(‘#country’).val(); $.ajax({ type: “POST”, url: “WebService.asmx/MakeEmployee”, data: “{name:'” + name + “‘,company:'” + company + “‘,location:'” + location + “‘,phonenumber:'” + phonenumber + “‘,country:'” + […]

JSONP和ASMX Web服务

我正在试图弄清楚如何使用jQuery对ASMX Web服务进行JSONP调用。 这些只是我已经阅读过的一些页面,但没有找到任何解决方案: 如何使用jquery“jsonp”调用外部Web服务? 使用jQuery将跨域JSON发布到ASP.NET 使用JQuery访问ASP.net webservice时出错 – JSONP 使用jQuery.ajax和JSONP设置标头? http://www.codeproject.com/Articles/43038/Accessing-Remote-ASP-NET-Web-Services-Using-JSONP http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/ 等等… 这是我的示例.NET Web方法: [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void GetEmployee(string employeeId, string callback) { // Get the employee object from the Factory. Employee requestedEmployee = EmployeeFactory.GetEmployee(employeeId); if(requestedEmployee != null) { // Return the padded JSON to the caller. CrossDomainUtility.SendJsonP(callback, requestedEmployee.ToJson()); […]

‘jquery’不是有效的脚本名称。 名称必须以’.js’结尾

我的ASP.Net项目运行良好,突然间我们出现电源故障。 当我运行我的网络应用程序时,它现在显示了很多 无法加载程序集Sanitizer ……“然后”无法加载“HtmlAgility …… 错误。 我可以通过使用Visual Studio 2012中的Manage Nuget Package Solutions卸载/重新安装它们来解决这些先前的错误。 但现在我遇到了另一个错误: ‘jquery’不是有效的脚本名称。 名称必须以’.js’结尾。“ 我尝试通过重新安装包来做同样的事情,但它不起作用。 我该怎么做才能解决这个问题? 我已经在我的root \ Scripts文件夹中有一个jquery.js文件。 我还在我的部分中添加了对此文件的引用: 但它仍然无法奏效。 请帮忙。

在ASP.NET MVC中使用AJAX刷新表

我想使用ajax更新MVC中的表。 我已经使用ajax在数据库中插入了数据。 我只想在插入新行后更新表格。 PS。 我试过搜索,但没有任何帮助我,我仍然困惑。 Here is my code: Main page View: @Html.Partial(“_IPTable”) “` Partial page View: ` ID Line Supplier @foreach (var item in ViewBag.IPTable)` { @item.ID @item.Line @item.Supplier } enter code here Controller view: public ActionResult Admin() { // get data from database return View(); } public ActionResult _IPTable() { return PartialView(); } […]

jquery在特定时间禁用按钮

我想在特定时间禁用按钮。 我怎样才能做到这一点?