I am doing something wrong and I can not figure out where...
I have this in my view - 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> I have this in my controller -
public ActionResult CreateForm(int nr) { ViewData["Nr"] = (nr++).ToString(); return PartialView(); } when I click on the Link I expect that the response to be loaded in my panel# (panel0,panel1...) but I am redirected to an empty page with only the returned content
this is the generated 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> and after click the page view source looks like this
<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> I have included Ajax js
<script src="/content/Microsoft/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> but I expected this to go into panel0... what am I doing wrong?
P.S.
Debuging with vs.net in MicrosoftMvcAjax.debug.js i get an error
around line 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