Designer Support for Selecting Web Form control

Discussion in 'ASP .Net Building Controls' started by Paul Ingles, Jul 19, 2003.

  1. Paul Ingles

    Paul Ingles Guest

    I've got a validator control that has somewhat limited designer support. It
    has an additional property that contains a string identifying another
    control on the form, e.g. "MyListBox".

    The BaseValidator control has a ControlToValidate property that does exactly
    what I need it to for this property, but was wondering how it actually
    works?

    I'd like it so that the VS.NET designer displays a drop-down list of all
    controls on the web form that are of type MyListBoxControl, so the developer
    can just select it and hey presto.

    Is this done using a custom designer, a custom type editor?

    Thanks for all suggestions,
    Paul
    Paul Ingles, Jul 19, 2003
    #1
    1. Advertising

  2. Hi Paul,

    You need a custom type converter. The BaseValidator.ControlToValidate
    property has a type converter of type
    System.Web.UI.WebControls.ValidatedControlConverter. This custom type
    converter does examine every control looking if they have the
    ValidationPropertyAttribute applied.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Paul Ingles" <paul@oobaloo-dot-co-dot-uk> wrote in message
    news:%...
    > I've got a validator control that has somewhat limited designer support.

    It
    > has an additional property that contains a string identifying another
    > control on the form, e.g. "MyListBox".
    >
    > The BaseValidator control has a ControlToValidate property that does

    exactly
    > what I need it to for this property, but was wondering how it actually
    > works?
    >
    > I'd like it so that the VS.NET designer displays a drop-down list of all
    > controls on the web form that are of type MyListBoxControl, so the

    developer
    > can just select it and hey presto.
    >
    > Is this done using a custom designer, a custom type editor?
    >
    > Thanks for all suggestions,
    > Paul
    >
    >
    Victor Garcia Aprea [MVP], Jul 19, 2003
    #2
    1. Advertising

  3. Paul Ingles

    Teemu Keiski Guest

    I'd like to follow up Victor's post so that here is an example how such
    converter is done from scratch to pick up all DataGrids on the Page.

    http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=212648

    Thanks,

    --
    Teemu Keiski
    MCP, Designer/Developer
    Mansoft tietotekniikka Oy
    http://www.mansoft.fi

    AspInsiders Member, www.aspinsiders.com
    ASP.NET Forums Moderator, www.asp.net
    AspAlliance Columnist, www.aspalliance.com


    "Victor Garcia Aprea [MVP]" <> wrote in message
    news:...
    > Hi Paul,
    >
    > You need a custom type converter. The BaseValidator.ControlToValidate
    > property has a type converter of type
    > System.Web.UI.WebControls.ValidatedControlConverter. This custom type
    > converter does examine every control looking if they have the
    > ValidationPropertyAttribute applied.
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    > To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    > and not by private mail.
    >
    > "Paul Ingles" <paul@oobaloo-dot-co-dot-uk> wrote in message
    > news:%...
    > > I've got a validator control that has somewhat limited designer support.

    > It
    > > has an additional property that contains a string identifying another
    > > control on the form, e.g. "MyListBox".
    > >
    > > The BaseValidator control has a ControlToValidate property that does

    > exactly
    > > what I need it to for this property, but was wondering how it actually
    > > works?
    > >
    > > I'd like it so that the VS.NET designer displays a drop-down list of all
    > > controls on the web form that are of type MyListBoxControl, so the

    > developer
    > > can just select it and hey presto.
    > >
    > > Is this done using a custom designer, a custom type editor?
    > >
    > > Thanks for all suggestions,
    > > Paul
    > >
    > >

    >
    >
    Teemu Keiski, Jul 19, 2003
    #3
  4. Paul Ingles

    Paul Ingles Guest

    Thanks very much for the link.

    "Teemu Keiski" <> wrote in message
    news:...
    > I'd like to follow up Victor's post so that here is an example how such
    > converter is done from scratch to pick up all DataGrids on the Page.
    >
    > http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=212648
    >
    > Thanks,
    >
    > --
    > Teemu Keiski
    > MCP, Designer/Developer
    > Mansoft tietotekniikka Oy
    > http://www.mansoft.fi
    >
    > AspInsiders Member, www.aspinsiders.com
    > ASP.NET Forums Moderator, www.asp.net
    > AspAlliance Columnist, www.aspalliance.com
    >
    >
    > "Victor Garcia Aprea [MVP]" <> wrote in message
    > news:...
    > > Hi Paul,
    > >
    > > You need a custom type converter. The BaseValidator.ControlToValidate
    > > property has a type converter of type
    > > System.Web.UI.WebControls.ValidatedControlConverter. This custom type
    > > converter does examine every control looking if they have the
    > > ValidationPropertyAttribute applied.
    > >
    > > --
    > > Victor Garcia Aprea
    > > Microsoft MVP | ASP.NET
    > > Looking for insights on ASP.NET? Read my blog:
    > > http://obies.com/vga/blog.aspx
    > > To contact me remove 'NOSPAM'. Please post all questions to the

    newsgroup
    > > and not by private mail.
    > >
    > > "Paul Ingles" <paul@oobaloo-dot-co-dot-uk> wrote in message
    > > news:%...
    > > > I've got a validator control that has somewhat limited designer

    support.
    > > It
    > > > has an additional property that contains a string identifying another
    > > > control on the form, e.g. "MyListBox".
    > > >
    > > > The BaseValidator control has a ControlToValidate property that does

    > > exactly
    > > > what I need it to for this property, but was wondering how it actually
    > > > works?
    > > >
    > > > I'd like it so that the VS.NET designer displays a drop-down list of

    all
    > > > controls on the web form that are of type MyListBoxControl, so the

    > > developer
    > > > can just select it and hey presto.
    > > >
    > > > Is this done using a custom designer, a custom type editor?
    > > >
    > > > Thanks for all suggestions,
    > > > Paul
    > > >
    > > >

    > >
    > >

    >
    >
    Paul Ingles, Jul 19, 2003
    #4
  5. I looked at the examples on ASP.NET, and have a suggestion. I similarly have
    a control which has a property which needs to be the ID of one of the other
    controls on the page. I used a TypeConverter derived from StringConverter to
    do this.

    However, instead of searching context.Container.Components, I used the
    IReferenceService. Here's the code in C#:

    public override TypeConverter.StandardValuesCollection
    GetStandardValues(ITypeDescriptorContext context)
    {
    IReferenceService service = (IReferenceService)
    context.GetService(typeof(IReferenceService));
    object[] references = service.GetReferences(typeof(Control));
    TypeConverter.StandardValuesCollection coll = new
    TypeConverter.StandardValuesCollection(references);
    return coll;
    }

    The following is an attempt to translate that into VB, but I won't have
    tested it:

    Public Overrides Function GetStandardValues(context as
    ITypeDescriptorContext) as TypeConverter.StandardValuesCollection
    Dim service as IReferenceService =
    CType(context.GetService(GetType(IReferenceService)), IReferenceService)
    Dim references() as Object = service.GetReferences(GetType(Control))
    Dim coll as New TypeConverter.StandardValuesCollection(references)
    Return coll
    End Function

    John Saunders



    "Teemu Keiski" <> wrote in message
    news:...
    > I'd like to follow up Victor's post so that here is an example how such
    > converter is done from scratch to pick up all DataGrids on the Page.
    >
    > http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=212648
    >
    > Thanks,
    >
    > --
    > Teemu Keiski
    > MCP, Designer/Developer
    > Mansoft tietotekniikka Oy
    > http://www.mansoft.fi
    >
    > AspInsiders Member, www.aspinsiders.com
    > ASP.NET Forums Moderator, www.asp.net
    > AspAlliance Columnist, www.aspalliance.com
    >
    >
    > "Victor Garcia Aprea [MVP]" <> wrote in message
    > news:...
    > > Hi Paul,
    > >
    > > You need a custom type converter. The BaseValidator.ControlToValidate
    > > property has a type converter of type
    > > System.Web.UI.WebControls.ValidatedControlConverter. This custom type
    > > converter does examine every control looking if they have the
    > > ValidationPropertyAttribute applied.
    > >
    > > --
    > > Victor Garcia Aprea
    > > Microsoft MVP | ASP.NET
    > > Looking for insights on ASP.NET? Read my blog:
    > > http://obies.com/vga/blog.aspx
    > > To contact me remove 'NOSPAM'. Please post all questions to the

    newsgroup
    > > and not by private mail.
    > >
    > > "Paul Ingles" <paul@oobaloo-dot-co-dot-uk> wrote in message
    > > news:%...
    > > > I've got a validator control that has somewhat limited designer

    support.
    > > It
    > > > has an additional property that contains a string identifying another
    > > > control on the form, e.g. "MyListBox".
    > > >
    > > > The BaseValidator control has a ControlToValidate property that does

    > > exactly
    > > > what I need it to for this property, but was wondering how it actually
    > > > works?
    > > >
    > > > I'd like it so that the VS.NET designer displays a drop-down list of

    all
    > > > controls on the web form that are of type MyListBoxControl, so the

    > > developer
    > > > can just select it and hey presto.
    > > >
    > > > Is this done using a custom designer, a custom type editor?
    > > >
    > > > Thanks for all suggestions,
    > > > Paul
    > > >
    > > >

    > >
    > >

    >
    >
    John Saunders, Jul 19, 2003
    #5
    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. SimonH
    Replies:
    2
    Views:
    310
    William F. Robertson, Jr.
    Feb 1, 2005
  2. Joergen Bech
    Replies:
    0
    Views:
    532
    Joergen Bech
    Jul 27, 2005
  3. Steve B.
    Replies:
    4
    Views:
    951
    Cheryl D Wise
    Jun 1, 2007
  4. Max2006
    Replies:
    2
    Views:
    504
    Max2006
    Jul 13, 2007
  5. Casper

    VS.NET designer support for nested custom web form controls

    Casper, Jun 8, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    107
    John Saunders
    Jun 9, 2004
Loading...

Share This Page