PDA

View Full Version : Simple Panel and Asp.Net Mvc



lucasite
7 May 2010, 10:58 AM
Hi,
Im having some terrible trouble trying to perform a simple task and was looking for some advice or help.
Im using Asp.Net MVC 2.0 and Im want to add a panel to my page, and have the contents loaded from a partial view.

My page contains the following js:

Ext.onReady(function() {
var p = new Ext.Panel({
title: 'My Panel',
collapsible: true,
renderTo: document.body,
width: 400,
height: 200
});

Ext.Ajax.request({
url: '/home/mockdata',
success: function(response) {
var o = Ext.decode(response.responseText);
p.add(o);
p.doLayout();
}
});
});


In my controller I have:


public PartialViewResult MockData()
{
return PartialView();
}


And my partialview contains something very simple:


<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<p>Lorem ipsum dolor sit amet.....</P>

However when my page loads, firebug shows the following error:


a.ownerCt.remove is not a function
[Break on this error] Ext.DomHelper=function(){var w=null,k=...lclick",this.onNodeDblClick,this)}});

This occurs after the get request. The response of the get request correctly contains the partialview.
Im not sure if I should be using Ext.decode(response.responseText).data in the jscript, but this doesnt help either.
Im abit stuck.

Any suggestions?

Luca

lucasite
7 May 2010, 11:32 AM
Incase anyone reads this in future, I think I solved the problem, although not sure if its the correct way or not.

Rather than performing an Ext.Ajax.request, I simply put:

p.load('/home/mockdata');