custom control wont work -

K

kal

I have registered my custom control in web.config as follows:
<add tagPrefix="PhoenixControls" namespace="PhoenixControls"
assembly="PhoenixControls"/>

I have added a file called phoenixcontrols.cs to App_Code folder and in this
file is this simple code:

namespace PhoenixControls

{

public class EncodeHtml : Control {

protected override void Render(HtmlTextWriter writer) {

LiteralControl lc;

lc = (LiteralControl) Controls[0];

writer.Write("This is a test" + lc.Text);

}}}


Including all the 'using' statements

Now I put this in a default.aspx page

<PhoenixControls:EncodeHtml>pc-control</PhoenixControls:EncodeHtml>

i get an error - EncodeHtml element is not known. the page displays but has
none of the custom control changes.

Help appreciated

Kal
 
K

Kevin Spencer

Your Control won't compile. It has errors in it. You have inherited Control,
and referenced "Controls[0]" - but there are no Controls in the Control.

You need to get and use some debugging tools and techniques. There are free
ASP.Net tools available from Microsoft. see
http://msdn.microsoft.com/vstudio/express/vwd/

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
G

Guest

Hi Kal,

<pages>
<controls>
<add assembly="__code" namespace="PhoenixControls"
tagPrefix="PhoenixControls"/>
</controls>
</pages>


hope this helps
 

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,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top