Literal content is not allowed within a UserControl

A

Ahsan Umair

Can I create a user control so that when I drop it on the web form I can put
text between the start and end tags as listed

<uc1:KeyFeatures id="KeyFeatures1" runat="server" >test..</uc1:KeyFeatures

Each one will have some lengthy text with bulleted lists, etc and I wanted
this for readability. Can I set a property to accept this "innerText" as a
value

When I do this I get

Literal content ('test..') is not allowed within a 'ASP.KeyFeatures_ascx'

I can add it as a property inside the start tag, but I wanted to do see if I
can do it this way.

Thanks, Ahsan
 
S

Stan

Can I create a user control so that when I drop it on the web form I can put
text between the start and end tags as listed

<uc1:KeyFeatures id="KeyFeatures1" runat="server" >test..</uc1:KeyFeatures

Each one will have some lengthy text with bulleted lists, etc and I wanted
this for readability. Can I set a property to accept this "innerText" as a
value

When I do this I get

Literal content ('test..') is not allowed within a 'ASP.KeyFeatures_ascx'

I can add it as a property inside the start tag, but I wanted to do see if I
can do it this way.

Thanks, Ahsan

Hi Ahsan

The short answer is No.

WebUserControls do not have an implied 'Text' or 'InnerText' property
with a value that can be declared in the manner you require. If you
need a control that has properties, methods etc that are not supported
using standard controls (Labels, Textboxes etc) and want to declare
property values between the tags then you need to create a Custom
control rather than a WebUserControl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top