0

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 

3 Answers 3

1

I have figured out my problem... it seams that the version of MicrosoftMvcAjax.js I was using was not up to date.... If you have similar problems as I had get latest version of mvccontrib...

Sign up to request clarification or add additional context in comments.

Comments

0

Did you remember to include the necessary javascript files before calling AjaxLink?

You need to reference MicrosoftAjax.js and MicrosoftMvcAjax.js for this to work correctly.

Comments

0

I have some experience with this kind of problem. It seems like we must use script file in a correct order to make it work. More specific, you should include MicrosoftAjax before MicrosoftMvcAjax script. Hope it helps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.