custom control wont work -

  • Thread starter Thread starter kal
  • Start date Start date
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
 
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
 
Hi Kal,

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


hope this helps
 
Back
Top