• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 225
  • Last Modified:

Another question about custom controls

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 ?
  • 3
1 Solution
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?
deersuperAuthor Commented:
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.
hey after u made the change..dod u recompile and then added the new one as a reference..that seems to be the problem
deersuperAuthor Commented:
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 !

deersuperAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now