"Text is not allowed between the opening and closing tag"?

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

  1. #1

    Default "Text is not allowed between the opening and closing tag"?

    Here's my custom control (taken and modified from ASP.NET Unleashed 2.0)...

    <cc1:ImageRotator ID="ImageRotator1" runat="server">
    <cc1:ImageItem AlternateText="first item..." />
    <cc1:ImageItem AlternateText="second item..." />
    <cc1:ImageItem>abc</cc1:ImageItem> <--ERROR appears here.
    </cc1:ImageRotator>

    However, the control runs and the literal content "abc" gets parsed OK.
    What do I have to do so Visual Studio doesn't show this error at compile or
    the IDE?. It works but is misleading if other developers want to use this
    control in their apps.

    The code for the ImageItem class is below...if literal text is placed
    between I want to default it to set the AlternatingText property. Just like
    the ListItem text defaults to the Text property.
    .....

    public class ImageItem : IParserAccessor
    {
    private string _imageUrl;
    private string _alternateText;

    public string ImageUrl
    {
    get { return _imageUrl; }
    set { _imageUrl = value; }
    }

    public string AlternateText
    {
    get { return _alternateText; }
    set { _alternateText = value; }
    }

    //only called when there is literal text placed between open/close
    tags
    public void AddParsedSubObject(object obj)
    {
    if (obj is LiteralControl)
    this.AlternateText = ((LiteralControl)obj).Text;
    else
    throw new System.Web.HttpException("Error parsing ImageItem
    class");
    }
    }
    Dave Guest

  2. Similar Questions and Discussions

    1. #39640 [NEW]: Segfault with "Allowed memory size exhausted"
      From: phpbugs at thequod dot de Operating system: Ubuntu Linux PHP version: 5CVS-2006-11-26 (CVS) PHP Bug Type: Reproducible...
    2. "Requested registry access is not allowed" and Web Service call
      Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that...
    3. #26356 [Fbk->Csd]: sporatic "Allowed memory size exhausted" errors
      ID: 26356 User updated by: my-junkmail at earthlink dot net Reported By: my-junkmail at earthlink dot net -Status: ...
    4. #26356 [Opn->Fbk]: sporatic "Allowed memory size exhausted" errors
      ID: 26356 Updated by: sniper@php.net Reported By: my-junkmail at earthlink dot net -Status: Open +Status: ...
    5. #26356 [Opn]: sporatic "Allowed memory size exhausted" errors
      ID: 26356 User updated by: my-junkmail at earthlink dot net Reported By: my-junkmail at earthlink dot net Status: ...
  3. #2

    Default RE: "Text is not allowed between the opening and closing tag"?

    The solution is to add:

    [PersistenceMode(PersistenceMode.InnerDefaultProper ty)]
    public string AlternateText
    { ...
    }



    "Dave" wrote:
    > Here's my custom control (taken and modified from ASP.NET Unleashed 2.0)...
    >
    > <cc1:ImageRotator ID="ImageRotator1" runat="server">
    > <cc1:ImageItem AlternateText="first item..." />
    > <cc1:ImageItem AlternateText="second item..." />
    > <cc1:ImageItem>abc</cc1:ImageItem> <--ERROR appears here.
    > </cc1:ImageRotator>
    >
    > However, the control runs and the literal content "abc" gets parsed OK.
    > What do I have to do so Visual Studio doesn't show this error at compile or
    > the IDE?. It works but is misleading if other developers want to use this
    > control in their apps.
    >
    > The code for the ImageItem class is below...if literal text is placed
    > between I want to default it to set the AlternatingText property. Just like
    > the ListItem text defaults to the Text property.
    > ....
    >
    > public class ImageItem : IParserAccessor
    > {
    > private string _imageUrl;
    > private string _alternateText;
    >
    > public string ImageUrl
    > {
    > get { return _imageUrl; }
    > set { _imageUrl = value; }
    > }
    >
    > public string AlternateText
    > {
    > get { return _alternateText; }
    > set { _alternateText = value; }
    > }
    >
    > //only called when there is literal text placed between open/close
    > tags
    > public void AddParsedSubObject(object obj)
    > {
    > if (obj is LiteralControl)
    > this.AlternateText = ((LiteralControl)obj).Text;
    > else
    > throw new System.Web.HttpException("Error parsing ImageItem
    > class");
    > }
    > }
    Dave 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