custom control wont work -

Discussion in 'ASP .Net' started by kal, Jun 5, 2007.

  1. kal

    kal Guest

    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
    kal, Jun 5, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:wxc9i.1639$...
    >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
    >
    >
    Kevin Spencer, Jun 6, 2007
    #2
    1. Advertising

  3. 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
    >
    >
    >
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Jun 7, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul M.

    .aspx page wont work!

    Paul M., Aug 2, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    472
    John Knoop
    Aug 2, 2003
  2. Gary

    defaultRedirect wont work

    Gary, Jan 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    390
    Steven Cheng[MSFT]
    Jan 26, 2004
  3. Fendi Baba

    Custom validation wont trigger

    Fendi Baba, Apr 28, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Bruno Piovan
    Apr 28, 2007
  4. Matt Sokol
    Replies:
    2
    Views:
    365
    Theo Tillotson
    Aug 7, 2003
  5. B. Rubble

    custom control works, but wont display in design time

    B. Rubble, May 12, 2005, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    151
    B. Rubble
    May 18, 2005
Loading...

Share This Page