HighTechTalks DotNet Forums  

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

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss "Text is not allowed between the opening and closing tag"? in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Dave
 
Posts: n/a

Default "Text is not allowed between the opening and closing tag"? - 09-08-2006 , 10:21 AM






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");
}
}

Reply With Quote
  #2  
Old   
Dave
 
Posts: n/a

Default RE: "Text is not allowed between the opening and closing tag"? - 09-08-2006 , 02:01 PM






The solution is to add:

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



"Dave" wrote:

Quote:
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");
}
}

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.