• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • 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>
      [DefaultProperty("Text"),
      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
            [Bindable(true),
            Category("Appearance"),
            DefaultValue("")]
            public string Text
            {
                  get
                  {
                        return text;
                  }

                  set
                  {
                        text = value;
                  }
            }
            [Bindable(true),Category("Misc")]
            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 ?
0
deersuper
Asked:
deersuper
  • 3
1 Solution
 
raterusCommented:
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?
0
 
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>
</body>

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.
0
 
praneethaCommented:
hey after u made the change..dod u recompile and then added the new one as a reference..that seems to be the problem
0
 
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 !

0
 
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 :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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