Custom properties in a User Control at Design time

Discussion in 'ASP .Net Web Controls' started by Nathan Bidwell, Sep 2, 2003.

  1. I have a user control I'm using to wrap the content of all pages on a
    site. I've successfully added a template property which will correctly
    render anything inside of it. The resulting aspx looks something like this:
    <%@ Page language="c#" Codebehind="wrapTest.aspx.cs"
    AutoEventWireup="false" Inherits="test.wrapTest" %>
    <%@ Register TagPrefix="uc1" TagName="wrapper"
    Src="controls/wrapper.ascx" %>
    <uc1:wrapper id="Wrapper" runat="server">
    <Title>A Test Page</Title>
    <Content>
    <asp:label runat="server" id="foo" Text="bar" />
    </Content>
    </uc1:wrapper>

    The problem is that Visual Studio's design view becomes useless with the
    message "Parser Error: Type 'System.Web.UI.UserControl' does not have a
    property named 'Title'." What I don't understand is why the designer
    doesn't pick up the derived UserControl type of 'wrapper'.

    Any help would be appreciated.

    Nathan
     
    Nathan Bidwell, Sep 2, 2003
    #1
    1. Advertising

  2. Hi,

    You have this problem because your custom control does not have a public
    ptoperty Title
    You have to create a public property E.g:

    --------------- yourControl.cs ---------------
    public string Title
    {
    set
    {
    _Title = value;
    }
    }

    private string _Title;

    --------------- End yourControl.cs ---------------


    Bye

    The Best Regards,
    Web Developer
    Michael Tkachev


    "Nathan Bidwell" <_> wrote in message
    news:...
    > I have a user control I'm using to wrap the content of all pages on a
    > site. I've successfully added a template property which will correctly
    > render anything inside of it. The resulting aspx looks something like

    this:
    > <%@ Page language="c#" Codebehind="wrapTest.aspx.cs"
    > AutoEventWireup="false" Inherits="test.wrapTest" %>
    > <%@ Register TagPrefix="uc1" TagName="wrapper"
    > Src="controls/wrapper.ascx" %>
    > <uc1:wrapper id="Wrapper" runat="server">
    > <Title>A Test Page</Title>
    > <Content>
    > <asp:label runat="server" id="foo" Text="bar" />
    > </Content>
    > </uc1:wrapper>
    >
    > The problem is that Visual Studio's design view becomes useless with the
    > message "Parser Error: Type 'System.Web.UI.UserControl' does not have a
    > property named 'Title'." What I don't understand is why the designer
    > doesn't pick up the derived UserControl type of 'wrapper'.
    >
    > Any help would be appreciated.
    >
    > Nathan
    >
     
    Michael Tkachev, Sep 3, 2003
    #2
    1. Advertising

  3. Unfortunately, I do have a public property which the designer just
    doesn't see correctly. The code compiles and runs correctly, it's just
    Visual Studio's designer view that gets confused.

    protected PlaceHolder title;
    public ITemplate Title
    {
    set
    {
    value.InstantiateIn(title);
    }
    }

    Thank you

    Nathan

    Michael Tkachev wrote:
    > Hi,
    >
    > You have this problem because your custom control does not have a public
    > ptoperty Title
    > You have to create a public property E.g:
    >
    > --------------- yourControl.cs ---------------
    > public string Title
    > {
    > set
    > {
    > _Title = value;
    > }
    > }
    >
    > private string _Title;
    >
    > --------------- End yourControl.cs ---------------
    >
    >
    > Bye
    >
    > The Best Regards,
    > Web Developer
    > Michael Tkachev
    >
    >
    > "Nathan Bidwell" <_> wrote in message
    > news:...
    >
    >>I have a user control I'm using to wrap the content of all pages on a
    >>site. I've successfully added a template property which will correctly
    >>render anything inside of it. The resulting aspx looks something like

    >
    > this:
    >
    >><%@ Page language="c#" Codebehind="wrapTest.aspx.cs"
    >>AutoEventWireup="false" Inherits="test.wrapTest" %>
    >><%@ Register TagPrefix="uc1" TagName="wrapper"
    >>Src="controls/wrapper.ascx" %>
    >><uc1:wrapper id="Wrapper" runat="server">
    >><Title>A Test Page</Title>
    >><Content>
    >><asp:label runat="server" id="foo" Text="bar" />
    >></Content>
    >></uc1:wrapper>
    >>
    >>The problem is that Visual Studio's design view becomes useless with the
    >>message "Parser Error: Type 'System.Web.UI.UserControl' does not have a
    >>property named 'Title'." What I don't understand is why the designer
    >>doesn't pick up the derived UserControl type of 'wrapper'.
    >>
    >>Any help would be appreciated.
    >>
    >>Nathan
    >>

    >
    >
    >
     
    Nathan Bidwell, Sep 3, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    740
  2. =?Utf-8?B?QW1pciBUb2hpZGk=?=

    Displaying user control properties at Design Time

    =?Utf-8?B?QW1pciBUb2hpZGk=?=, Jun 25, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    401
    =?Utf-8?B?QW1pciBUb2hpZGk=?=
    Jun 25, 2007
  3. Peter

    properties not showing in properties window at design time

    Peter, Dec 10, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    229
    Lostinet.Web Support
    Dec 10, 2003
  4. George
    Replies:
    4
    Views:
    201
    Jeffrey Tan[MSFT]
    Jan 19, 2004
  5. N Kumar

    Setting web custom control properties at design time

    N Kumar, Feb 21, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    175
    Teemu Keiski
    Feb 23, 2006
Loading...

Share This Page