Results 1 to 4 of 4

Thread: Problem - DI to a page having .NET 2.0 Master page

  1. #1
    Join Date
    Jul 2007
    Posts
    2

    Default Problem - DI to a page having .NET 2.0 Master page

    Hi,

    For last 2 days I'm struggling to inject a message to a page having .NET 2.0 master page (not Spring master pages). It works perfectly on pages without a master page.

    I tested on 1.0.2 and 1.1 latest version but without any success. I have the following in my web.conf.

    Code:
      <spring>
        <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
          <resource uri="config://spring/objects"/>
        </context>
        <objects xmlns="http://www.springframework.net"> 
          <object type="~/pages/ContentPage.aspx">
            <property name="Title" value="Spring DI"/>
          </object>
          <object type="~/pages/PlainPage.aspx">
            <property name="Title" value="Spring DI"/>
          </object>
        </objects>
      </spring>
    "PlainPage.aspx" has no master page definition and it works well. "ContentPage.aspx" is the page which has .NET 2.0 master page and it doesn't work at all.

    I'm quite surprised to see no Google post on this matter. Am I doing something totally stupid ? Please advice.

    Thanks in advance
    Hasith

  2. #2
    Join Date
    Jul 2007
    Posts
    2

    Default

    Hay this is really interesting. It seems I'm able to inject properties other than "Page.Title".

    I added a new DI property ("Message") and now my configuration looks like following:

    Code:
      <spring>
        <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">
          <resource uri="config://spring/objects"/>
        </context>
        <objects xmlns="http://www.springframework.net"> 
          <object type="~/pages/ContentPage.aspx">
            <property name="Title" value="Spring DI"/>
            <property name="Message" value="Spring DI Message"/>
          </object>
          <object type="~/pages/PlainPage.aspx">
            <property name="Title" value="Spring DI"/>
          </object>
        </objects>
      </spring>
    Injection happens for property "Message", but not for property "Title" even on the same page (ContentPage.aspx).

    I think I have selected a really strange starting point to Spring by using "Page.Title" in my tests. Can anyone explain what is happening here?

    Hasith

  3. #3
    Join Date
    Nov 2006
    Posts
    54

    Thumbs up

    Not sure if it helps you, but I'm using Spring to do DI into Pages & Master Pages with ASP.Net, my configuration [the relevant bits] is as follows:
    Code:
    <object type="Default.master" abstract="true">
      <property name="SomeMagicStrategy" ref="SomeMagicStrategy"/>
    </object>
    
    <object id="BasePage" abstract="true">
      <property name="MasterPageFile" value="~/Default.master"/>
    </object>
    
    <object type="Default.aspx" parent="BasePage"/>
    I can't comment on setting Page title however, sorry dude
    - Cj

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

    Default

    Hi,

    Quote Originally Posted by Hasith View Post
    It seems I'm able to inject properties other than "Page.Title".
    It seems your title goes /dev/null. Don't you get any exception?

    How does your masterpage.master and context.aspx <head> html code look like?

    Maybe you placed the <head runat=Server> element on your content.aspx outside a <asp:content> element?

    hope this helps,
    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
  •