New to Controls - help with Checkbox RenderContents(...)

Discussion in 'ASP .Net Building Controls' started by Ryan Ternier, Jun 7, 2005.

  1. Ryan Ternier

    Ryan Ternier Guest

    I'm new to creating controls, so I wanted to start with something simple.


    A simple checkbox, but with a small footer tag underneath the acual text
    to put anything you want.

    I'm not worried about the formatting yet, that's easy to do. My question
    lies with the RenderContents() method. In my user control, it's not
    even fireing mine, it's displaying a regular check box.

    here's the code:

    private string footNoteCss;
    private string footNote;
    public string FootNoteCss
    {
    get
    {
    return (footNoteCss != null ? footNoteCss:String.Empty);
    }
    set
    {
    footNoteCss = value;
    }
    }

    public string FootNote
    {
    get
    {
    return (footNote != null ? footNote : String.Empty);
    }
    set
    {
    footNote = value;
    }
    }

    //Overrides the REnderContents method
    protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
    {
    writer.Write(ActivateFootNote(base.Text));
    }

    private string ActivateFootNote(string theText)
    {
    string buf = theText + "<div class='" + footNoteCss + "'>" + footNote
    + "</div>";
    return buf;
    }
    }


    -----

    I've overriden the Render event, and it calls mine fine, but I don't
    want to override Render... i want to override the content.

    Any suggestions?

    /RT
     
    Ryan Ternier, Jun 7, 2005
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.