Custom Control Property Problem

Last post 09-07-2005 6:30 AM by andyajp141. 7 replies.

Sort Posts:

  • Custom Control Property Problem

    09-05-2005, 4:46 PM
    • Member
      25 point Member
    • andyajp141
    • Member since 09-05-2005, 4:39 PM
    • Posts 5
    Hi,

    I'm trying to develop a proper label control which will include a 'for' attribute. I would like to build this with functionality like the 'controltovalidate' property of a validator. The idea is that in the property window, I will be able to select a control on the page to relate the label to.

    I think I might need to do something like:
    <editor(...........)> Property.........

    I new to writing custom controls so any help is greatly appreciated.

    Regards,
    Andy
  • Re: Custom Control Property Problem

    09-06-2005, 4:29 AM
    • Contributor
      4,983 point Contributor
    • orzeh
    • Member since 07-28-2005, 11:18 AM
    • Poland
    • Posts 897
    hi!

    use this attributes:
    [IDReferencePropertyAttribute(typeof( <specify type>  )),
     TypeConverter(typeof(ControlIDConverter))]

    orzeh

    code less, think more!
  • Re: Custom Control Property Problem

    09-06-2005, 11:29 AM
    • Member
      25 point Member
    • andyajp141
    • Member since 09-05-2005, 4:39 PM
    • Posts 5
    Hi,

    Thanks for the reply, however I am not sure exactly what you mean.
    I am writing in vb so I have converted your code to what is shown below. However I am having trouble with the attribute 'IDReferencePropertyAttribute' and the type 'ControlIDConverter', VS is complaining that they are both undefined. I have searched the documentation and cannot find reference to them in any namespace. What Am I doing wrong?? 

    <IDReferencePropertyAttribute(GetType(System.Web.UI.Control)), TypeConverter(GetType(ControlIDConverter))>

    Thanks,

    Andy

  • Stick out tongue [:P] Re: Custom Control Property Problem

    09-06-2005, 2:47 PM
    • Contributor
      4,983 point Contributor
    • orzeh
    • Member since 07-28-2005, 11:18 AM
    • Poland
    • Posts 897
     andyajp141 wrote:
    Hi,

    However I am having trouble with the attribute 'IDReferencePropertyAttribute' and the type 'ControlIDConverter', VS is complaining that they are both undefined. I have searched the documentation and cannot find reference to them in any namespace. What Am I doing wrong??


    hello,

    they are defined in System.Web.UI namespace, but in framework 2.0.
    sorry that I didn`t mention it :)

    orzeh
    code less, think more!
  • Re: Custom Control Property Problem

    09-06-2005, 7:15 PM
    • Member
      25 point Member
    • andyajp141
    • Member since 09-05-2005, 4:39 PM
    • Posts 5
    Sad [:(] I'm only using 1.1 on this project. Any ideas if this can be done with 1.1?

    Thanks,
    Andy
  • Embarrassed [:$] Re: Custom Control Property Problem

    09-07-2005, 4:56 AM
    • Contributor
      4,983 point Contributor
    • orzeh
    • Member since 07-28-2005, 11:18 AM
    • Poland
    • Posts 897
    hi!

    You can try what I`ve done :-)
    Open MSIL Disassembler. load from %Windir%\Microsoft.NET\Framework\<version> dll that contains the validator control. (system.web.dll )
    then find in namespace BaseValidator class (System.Web.UI.WebControls) . then expand it`s node and find ControlToValidate property (with red triangle). click it.
    You`ll something like this:
      .custom instance void System.Web.UI.IDReferencePropertyAttribute::.ctor() = ( .... )
      .custom instance void System.Web.WebSysDescriptionAttribute::.ctor(string) = ( ...)

    this is what we`re looking for.
    I know its "hardcore" solution, but it solved my problems :)

    orzeh



    code less, think more!
  • Re: Custom Control Property Problem

    09-07-2005, 6:08 AM
    • Member
      25 point Member
    • andyajp141
    • Member since 09-05-2005, 4:39 PM
    • Posts 5
    Hi,

    I had tried using ildasm earlier to look at the basevalidator, however, I was not quite sure what to do with the information it contains. I am trying to play around with some of the objects named below but I'm still struggling.

    .property instance string ControlToValidate()
    {
      .custom instance void System.Web.WebSysDescriptionAttribute::.ctor(string) = ( ...... )                                   
      .custom instance void [System]System.ComponentModel.TypeConverterAttribute::.ctor(class [mscorlib]System.Type) = ( ...... )      
      .custom instance void System.Web.WebCategoryAttribute::.ctor(string) = ( ...........)          
      .custom instance void [System]System.ComponentModel.DefaultValueAttribute::.ctor(string) = ( .... )
      .set instance void System.Web.UI.WebControls.BaseValidator::set_ControlToValidate(string)
      .get instance string System.Web.UI.WebControls.BaseValidator::get_ControlToValidate()
    } // end of property BaseValidator::ControlToValidate

    Thanks for all the help so far,
    Andy
  • Re: Custom Control Property Problem

    09-07-2005, 6:30 AM
    • Member
      25 point Member
    • andyajp141
    • Member since 09-05-2005, 4:39 PM
    • Posts 5
    Hi,

    I've just tried examining the BaseValidator using a tool called reflector. It gives the following information for the controltovalidate property:

    [WebSysDescription("BaseValidator_ControlToValidate"), TypeConverter(typeof(ValidatedControlConverter)), WebCategory("Behavior"), DefaultValue("")]

    However when I try to use WebSysDescription in my control VS complains that it is declared private so this may also be a nonstarter.

    Any more ideas? Am I going to wrong way about this?

    Andy
Page 1 of 1 (8 items)