Asp.net mvc asp.net mvc Ajax.ActionLink问题
我做错了什么,我不知道在哪里 我的视图中有这个-CreateForm.aspxAsp.net mvc asp.net mvc Ajax.ActionLink问题,asp.net-mvc,asp.net-ajax,Asp.net Mvc,Asp.net Ajax,我做错了什么,我不知道在哪里 我的视图中有这个-CreateForm.aspx <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %> <%= this.Ajax.ActionLink("Create New", "CreateForm", new { nr=ViewData["Nr"]??0 }, new AjaxOptions { UpdateTargetId = "pane
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%= this.Ajax.ActionLink("Create New", "CreateForm", new { nr=ViewData["Nr"]??0 }, new AjaxOptions { UpdateTargetId = "panel" + (String.IsNullOrEmpty((string)ViewData["Nr"]) ? "0" : "1") }, new { id = "panel" + (String.IsNullOrEmpty((string)ViewData["Nr"]) ? "0" : "1") + "Form" })%>
<div id="panel<%=String.IsNullOrEmpty((string)ViewData["Nr"])?"0":"1"%>"></div>
当我点击链接时,我希望响应被加载到我的面板(面板0,面板1…)中,但我被重定向到一个只有返回内容的空页面
这是生成的html
<a href="/Member.aspx/CreateForm?nr=0" id="panel0Form" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'panel0' });">Create New</a>
<div id="panel0"></div>
单击后,页面视图源代码如下所示
<a href="/Member.aspx/CreateForm?nr=0" id="panel1Form" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: 'panel1' });">Create New</a>
<div id="panel1"></div>
我已经包括了Ajax js
<script src="/content/Microsoft/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
但我以为这会进入第0组。。。我做错了什么
附言
在MicrosoftMvcAjax.debug.js中使用vs.net进行调试时,我遇到一个错误
在3063线附近
var e = Function._validateParams(arguments, [
{name: "id", type: String},
{name: "element", mayBeNull: true, domElement: true, optional: true}
]);
if (e) throw e; <-here it trows an error
var e=Function.\u验证图(参数、[
{name:“id”,类型:String},
{name:“元素”,mayBeNull:true,domeElement:true,可选:true}
]);
如果(e)抛出e 您是否记得在调用AjaxLink之前包含必要的javascript文件
你需要参考MicrosoftAjax.js和MicrosoftMvcAjax.js才能正常工作。我已经解决了我的问题。。。我使用的MicrosoftMvcAjax.js的版本不是最新的,这是很明显的。。。。
如果您遇到与我获得最新版本的mvccontrib类似的问题…我对此类问题有一些经验。似乎我们必须以正确的顺序使用脚本文件才能使其正常工作。更具体地说,应该在MicrosoftMvcAjax脚本之前包含MicrosoftJAX。
希望能有帮助
var e = Function._validateParams(arguments, [
{name: "id", type: String},
{name: "element", mayBeNull: true, domElement: true, optional: true}
]);
if (e) throw e; <-here it trows an error