views:

102

answers:

2

I have installed the AJAX Control Toolkit following the included instructions and I'm trying to add a TabContainer with a couple of TabPanels to a view in an ASP.NET MVC application. Is this possible? I can get the TabContainer and TabPanel controls to work in a Webforms application but not in MVC.

In one of my views I have the following code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.Class1>" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <form id="form1" runat="server">

    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>

    <h2>Create</h2>

    <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1">

        <ajaxToolkit:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
        <ContentTemplate>
        </ContentTemplate>
        </ajaxToolkit:TabPanel>

        <ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
        <ContentTemplate>
        </ContentTemplate>
        </ajaxToolkit:TabPanel>

    </ajaxToolkit:TabContainer>

    </form>

</asp:Content>

The above gives an HttpException "OutputStream is not available when a custom TextWriter is used." Keeping the TabContainer but removing the TabPanel does not raise any errors.

Any suggestions?

Thanks.

+1  A: 

The ajax control toolkit is quite tightly coupled to ASP.NET WebForms, which often don't work with MVC. You might be better off using something like jQuery UI: http://jqueryui.com/demos/tabs/

marcind
A: 

I think I've found the answer here http://stackoverflow.com/questions/3086894/what-is-causing-this-error-error-executing-child-request-for-handler-system-web

The AJAX Control Toolkit controls are server controls and are not supported in ASP.NET MVC.

Looks like the best options are to use the javascript directly from the control toolkit or to use some other Javascript like JQuery as suggested by marcind.

Luke CK

related questions