Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > custom control wont work -

Reply
Thread Tools

custom control wont work -

 
 
kal
Guest
Posts: n/a
 
      06-05-2007
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


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      06-06-2007
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

"kal" <(E-Mail Removed)> wrote in message
news:wxc9i.1639$(E-Mail Removed)...
>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
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      06-07-2007
Hi Kal,

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


hope this helps
--
Milosz


"kal" wrote:

> 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wont start,wont stop hunty Computer Support 4 06-04-2006 05:26 PM
custom control works, but wont display in design time B. Rubble ASP .Net Building Controls 4 05-18-2005 11:38 AM
Capturing event from other custom control within another custom control Jonah Olsson ASP .Net 1 04-05-2005 01:39 PM
How to get custom control to work with custom validator Scott Yenor ASP .Net Web Controls 0 01-27-2004 12:37 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments