Results 1 to 6 of 6

Thread: spring:head and ajax control toolkit

  1. #1
    Join Date
    Oct 2006
    Location
    Amsterdam, Netherlands
    Posts
    22

    Default spring:head and ajax control toolkit

    Hi all,

    My ASP.NET 2.0 webapp uses a Masterpage (Spring.Web.UI.Masterpage). Pages extend Spring.Web.UI.Page. This all works fine. I added Spring Ajax integration as well, this also works fine. However, when using the AjaxControlToolkit, e.g. the MaskedEditExtender, I get the following error:

    Code:
    [NullReferenceException: Object reference not set to an instance of an object.]
       AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) +295
       AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) +138
    When googling to resolve this problem I found this: http://odetocode.com/Blogs/scott/arc.../25/10627.aspx.

    It states "that the themes feature in ASP.NET 2.0 relies on an active header control to inject style sheets, I figured the ScriptObjectBuilder used the same trick to inject new script tags".

    When using a <head> tag with runat="server" the problem is fixed indeed, but then the
    Code:
    <%= Page.CssRoot %>
    that works because of the spring:head tag doesn't work anymore...

    Is this an issue with the spring:head tag? Are there any fixes or workarounds?

    Thanks in advance,
    EJ

  2. #2
    Join Date
    Jan 2006
    Location
    Cambridge, UK
    Posts
    1,340

    Default

    Hi,

    could you maybe provide a bit more of your .aspx code?

    tx,
    Erich

  3. #3
    Join Date
    Oct 2006
    Location
    Amsterdam, Netherlands
    Posts
    22

    Default

    Hi Erich,

    Thanks for your reaction.

    This is the MasterPage with original spring:head tag

    Code:
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.Master.cs" Inherits="EJSSD.BrokerTool.Web.SiteMaster" Debug="true"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
      <spring:Head id="Head1" runat="server">
        <link href="<%= Page.CssRoot %>/default.css" type="text/css" rel="stylesheet" />
        <title><%= GetMessage("default.title") %></title>
        <asp:ContentPlaceHolder id="head" runat="server" />
      </spring:Head>
      <body>
        <form id="form" method="post" runat="server">
          <div id="container">
            <div id="logo">
              <spring:LocalizedImage id="logoImage" imageName="spring-air-logo.jpg" borderWidth="0" runat="server" />
            </div>
            <div id="content">
           ................
    which gives the error described above, when used with this content page:

    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EditApplication.aspx.cs" Inherits="EJSSD.BrokerTool.Web.EditApplication" %>
    <asp:content id="editAppContent" contentplaceholderid="body" runat="server">
        <table cellspacing="0" cellpadding="0" width="90%" align="center" border="0">
            <tr>
                <td>
                    <asp:label id="lblAppName" runat="server" text="Name"/>
                </td>
                <td>
    				<asp:textbox id="txtAppName" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:label id="lblStartDate" runat="server" text="Start date"/>
                </td>
                <td>
    				<asp:textbox id="txtStartDate" runat="server" />
    				<ajaxToolkit:CalendarExtender id="startDateExtender" runat="server" TargetControlID="txtStartDate"
    				 Format="dd-MM-yyyy"/>
                </td>
            </tr>
    ..................
    I colored the AjaxControlToolkit tag to better show where it is used.

    Problem is not present when changing the Masterpage to:
    Code:
    .........
    <head id="head" runat="server">
    	<title>Survey</title>
    	<link href="css/default.css" type="text/css" rel="stylesheet" />
    </head>
    ............

    Thanks so far,
    EJ

  4. #4
    Join Date
    Jan 2006
    Location
    Cambridge, UK
    Posts
    1,340

    Default

    Hi,

    Please try nesting <spring:Head> within asp.net's <head>:

    Code:
    <html xmlns="http://www.w3.org/1999/xhtml" >
      <head runat="server">
        <spring:Head runat="server">
          <link href="<%= Page.CssRoot %>/default.css" type="text/css" rel="stylesheet" />
          <title><%= GetMessage("default.title") %></title>
        </spring:head>
          <asp:ContentPlaceHolder id="head" runat="server" />
      </head>
    ...
    unfortunately it has not been possible to merge the 2 functionalities. Thus if you need both, <spring:head> allows to be nested within standard <head> tag.

    -Erich

  5. #5
    Join Date
    Oct 2006
    Location
    Amsterdam, Netherlands
    Posts
    22

    Default

    Thanks Erich, that works fine..., albeit with two heads...

    Cheers,
    EJ

  6. #6
    Join Date
    Jan 2006
    Location
    Cambridge, UK
    Posts
    1,340

    Default

    Hi,

    I know it's not beautiful. But as long as NET framework developers tend to make everything sealed and private, I'm afraid there's little choice :-(

    -Erich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •