String Array Property produces Parser Error

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default String Array Property produces Parser Error

    Dear readers,

    I'm having problems with creating a custom control that accepts an
    array of strings as a property. First I used the following code which
    produced a Parser Error

    <Bindable(True), Category(_ClassName)> _
    Public Property [MenuItems]() As String()
    Get
    Return CType(ViewState("__stringMenuItems"), String())
    End Get
    Set(ByVal Value As String())
    ViewState("__stringMenuItems") = Value
    End Set
    End Property

    Afterwards I tried several attributes, one of them
    (PersistenceMode(PersistenceMode.InnerDefaultPrope rty)) produces
    additional "html" tags but this doesn't work either.

    Does anyone know how to solve this?

    Many thanks,
    Rémy Samulski

    Rémy Samulski Guest

  2. Similar Questions and Discussions

    1. #40424 [NEW]: Fatal error when setting the value of COM object's property array
      From: lee at dark-circuit dot com Operating system: Windows XP SP2 PHP version: 5CVS-2007-02-10 (snap) PHP Bug Type: COM...
    2. Array String Property
      Hi. I'm newer in asp.net. I doing a derived control of TextBox. well y using a property of array string. But when i use this property in design...
    3. Parser Error: Type XYZ does not have a property named 'cc3:MyItems' (complete posting) ASP.NET Web Control Error
      I am having problems trying to get this part of the functionality working on my control and I hope somebody has a clue about how to resolve it. ...
    4. Error Creating Control: Parser Error DocHeader does not have a property named 'cc3:MyItems'
      I am having problems getting this webcontrol working properly. Everything else works fine except having items. So here is the low-down on the...
    5. Array to string conversion error - why?
      I get the following error: Notice: Array to string conversion in C:\Documents and Settings\ShepMode\Desktop\Websites\ShareMonkey.net\Web\join.php...
  3. #2

    Default Re: String Array Property produces Parser Error

    Rémy,
    it is fully possible to create a property who's underlying type is a
    string array. rather then dealing with the sizing issues of a static
    array though, perhaps you could make that property an Arraylist or
    Hashtable?

    Mike MacMillan

    Rémy Samulski wrote:
    > Dear readers,
    >
    > I'm having problems with creating a custom control that accepts an
    > array of strings as a property. First I used the following code which
    > produced a Parser Error
    >
    > <Bindable(True), Category(_ClassName)> _
    > Public Property [MenuItems]() As String()
    > Get
    > Return CType(ViewState("__stringMenuItems"), String())
    > End Get
    > Set(ByVal Value As String())
    > ViewState("__stringMenuItems") = Value
    > End Set
    > End Property
    >
    > Afterwards I tried several attributes, one of them
    > (PersistenceMode(PersistenceMode.InnerDefaultPrope rty)) produces
    > additional "html" tags but this doesn't work either.
    >
    > Does anyone know how to solve this?
    >
    > Many thanks,
    > Rémy Samulski
    Mike MacMillan Guest

  4. #3

    Default Re: String Array Property produces Parser Error

    Dear Mike,

    Thx for replying my question but I don't have any problems with sizing
    issues of a string array. What I'm trying to do is to make a custom
    control that can be set on design time in Visual Studio.net 2003.
    That's why I have chosen a String array and not for example an
    ArrayList (which can't be filled on design-time (one can only add
    Objects without filling the values). Everything works well except when
    I fill the String Array the HTML code of the concerned object is:

    <cc1:TabPages id="TabPages4" runat="server" MenuItems="String[]
    Array"></cc1:TabPages>

    The parser than (after saving and reopening the WebForm) throws an
    parser error stating it can't create an object of type
    'System.String[]' from its string representation 'String[] Array' for
    the 'MenuItems' property.

    When I insert the
    (PersistenceMode(PersistenceMode.InnerDefaultPrope rty)) attribute in
    the code above (see first post) the HTML code changes to:

    <cc1:TabPages id="TabPages5" runat="server">
    <System.String Length="4"></System.String>
    <System.String Length="8"></System.String>
    </cc1:TabPages>

    But now the parser return the error: '' could not be set on property
    'MenuItems'. Furthermore when I select the view HTML the HTML code
    shows the error: The active schema does not support the element
    'System.String'.

    Anyone an example on how to implement an array property which can be
    edited on design time?

    Many thanks,
    Rémy

    Rémy Samulski Guest

  5. #4

    Default Re: String Array Property produces Parser Error

    Remy,
    it is possible to have a variable represet a string array, but there
    will need to be a bit of extra work on your side. if this property
    will be hardcoded into the tag, you can build the property perhaps
    during the AddParsedSubObject method of the page/control that contains
    your custom control. ex:

    <cc1:Something someAttrib="12,33,45,66,77,823,12"/>

    this could be parsed into an int or string array during the
    AddParsedSubObject method (or OnInit, or whatever...). you could even
    provide a custom Set accessor for the property that exposes this array,
    and parse the deliminated string there. easy answer though, you won't
    be able to define on the frontend the contents of the array, you will
    need a bit of manual work to make it an array.

    Mike


    Rémy Samulski wrote:
    > Dear Mike,
    >
    > Thx for replying my question but I don't have any problems with sizing
    > issues of a string array. What I'm trying to do is to make a custom
    > control that can be set on design time in Visual Studio.net 2003.
    > That's why I have chosen a String array and not for example an
    > ArrayList (which can't be filled on design-time (one can only add
    > Objects without filling the values). Everything works well except when
    > I fill the String Array the HTML code of the concerned object is:
    >
    > <cc1:TabPages id="TabPages4" runat="server" MenuItems="String[]
    > Array"></cc1:TabPages>
    >
    > The parser than (after saving and reopening the WebForm) throws an
    > parser error stating it can't create an object of type
    > 'System.String[]' from its string representation 'String[] Array' for
    > the 'MenuItems' property.
    >
    > When I insert the
    > (PersistenceMode(PersistenceMode.InnerDefaultPrope rty)) attribute in
    > the code above (see first post) the HTML code changes to:
    >
    > <cc1:TabPages id="TabPages5" runat="server">
    > <System.String Length="4"></System.String>
    > <System.String Length="8"></System.String>
    > </cc1:TabPages>
    >
    > But now the parser return the error: '' could not be set on property
    > 'MenuItems'. Furthermore when I select the view HTML the HTML code
    > shows the error: The active schema does not support the element
    > 'System.String'.
    >
    > Anyone an example on how to implement an array property which can be
    > edited on design time?
    >
    > Many thanks,
    > Rémy
    Mike MacMillan Guest

  6. #5

    Default Re: String Array Property produces Parser Error

    Dear Mike,

    OK this is the "over my head" stuff. Is it possible to add some
    attribute to a property that will prevent the value to be set in the
    HTML? What I'm proposing is 2 properties: one will be the in the
    background property that isn't visible in the IDE (<Browsable(False),
    EditorBrowsable(EditorBrowsableState.Never)>). This background property
    will be a string that has to be splitted to get the array we want. The
    other is a array property that can be edited using the IDE, but it
    shouldn't add any values in the HTML part in order to not rise a parser
    error.

    Hmm, hope it is clear what I'm trying to say =(

    Many thanks for your previous answers hope you can help me out with
    this,
    Rémy

    Rémy Samulski Guest

  7. #6

    Default Re: String Array Property produces Parser Error

    Remy,
    so what you're saying is you'd like to have 2 properties; one will
    return string and will hold a delimited set of data, the other will be
    an array and will hold the delimited data in a strongly typed array.
    further, you'd like the user to modify the array's contents using the
    IDE, and have that persist the correct delimited string in the string
    property? you will need custom design time support for your control to
    set the contents of that property correctly. also, being the IDE can't
    see the string property, users coding directly(such as with notepad)
    will still see the string property as a valid property to assign to.

    Mike MacMillan

    Rémy Samulski wrote:
    > Dear Mike,
    >
    > OK this is the "over my head" stuff. Is it possible to add some
    > attribute to a property that will prevent the value to be set in the
    > HTML? What I'm proposing is 2 properties: one will be the in the
    > background property that isn't visible in the IDE (<Browsable(False),
    > EditorBrowsable(EditorBrowsableState.Never)>). This background property
    > will be a string that has to be splitted to get the array we want. The
    > other is a array property that can be edited using the IDE, but it
    > shouldn't add any values in the HTML part in order to not rise a parser
    > error.
    >
    > Hmm, hope it is clear what I'm trying to say =(
    >
    > Many thanks for your previous answers hope you can help me out with
    > this,
    > Rémy
    Mike MacMillan Guest

  8. #7

    Default Re: String Array Property produces Parser Error

    Use the TypeConverter(GetType(StringArrayConverter)) attribute
    Unregistered Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139