【发布时间】:2013-02-26 04:07:17
【问题描述】:
我做错了,我不知道在哪里......
我认为这是 - 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 = "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>
我的控制器中有这个 -
public ActionResult CreateForm(int nr)
{
ViewData["Nr"] = (nr++).ToString();
return PartialView();
}
当我点击链接时,我希望响应加载到我的面板# (panel0,panel1...) 但我被重定向到一个只有返回内容的空页面
这是生成的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>
但我希望这会进入 panel0...我做错了什么?
附言
在 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
【问题讨论】: