Another question about custom controls

Posted on 2005-04-29
Last Modified: 2010-04-07
I am using the Wrox book for custom controls.

I am using their examples and everything they have in their examples works just fine but if I make slight additions to the code I dont see the change I have made being reflected.

my code is as given below (the portion I made I will indicate):

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace TestControlNameSpace2
      /// <summary>
      /// Summary description for WebCustomControl1.
      /// The Client Web Form is Called TestControlClient2.aspx
      /// </summary>
      ToolboxData("<{0}:TestControl2 runat=server></{0}:TestControl2>")]
      public class TestControl2 : System.Web.UI.WebControls.WebControl
            private string text;
            private string message;
            private string anotherMessage;    -------> I ADDED TO THE BOOKS CODE
            public string Text
                        return text;

                        text = value;
            public string ExMessage
                  get{return message;}
                  set {message=value;}
            [Bindable(true),Category("Misc")]             ----------------------------------------------------------------->
            public string AnotherMessage                  |
            {                                                          |
                  get{return anotherMessage;}  |    EVERYTHING I ADDED
                  set{anotherMessage=value;}   |
            }                                                            |----------------------------------------------------------------->

            /// <summary>
            /// Render this control to the output parameter specified.
            /// </summary>
            /// <param name="output"> The HTML writer to write out to </param>
            protected override void Render(HtmlTextWriter output)
                  output.Write(text+" "+message+" "+anotherMessage); ----->anotherMessage I Added

I hope my code is clear to understand and now for the problem ....
I added string anotherMessage and its accessor and setter method WHICH IS EXACTLY LIKE THE ExMessage method.
I basically copied the ExMessage code for AnotherMessage and in Render method I added anotherMessage as a part of the string.

It does not work.... I am surprised WHY ? I didnt do anything fancy here ... just copy paste.
Without the anotherMessage everything looks and works great !
What do you think ?
Question by:deersuper
    LVL 33

    Expert Comment

    Can you show the code you are using in your aspx page to set values in the control.  What exactly isn't working too, error, blank text?
    LVL 2

    Author Comment

    the code that is not working is :

    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <cc1:TestControl2 id="TestControl22" runat="server" Text="rrrr" AnotherMessage="wwww" ExMessage="eeee"></cc1:TestControl2></form>

    Text = "rrr" renders so does ExMessage but AnotherMessage does not.

    and from the .cs file code I have provided it is clear that AnotherMessage is like a twin of the ExMessage.
    LVL 15

    Accepted Solution

    hey after u made the change..dod u recompile and then added the new one as a reference..that seems to be the problem
    LVL 2

    Author Comment

    I figured out the problem ! the updated control was not being added to the control list !
    I had to manually remove reference to the control and then also remove it from toolbox and re do these 2 steps again.

    Worked fine then !

    LVL 2

    Author Comment

    ur answer showed up later after I had posted my comments but what you say is exactly what the problem is !

    thanks ... I ll have another question about custom controls soon..... lol :)

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now