in

ASP.NET Weblogs

Andy Smith's Blog

Page.RegisterStartupScript('Andy', 'MetaBuilders_WebControls_GainKnowledge();');

March 2004 - Posts

  • Starting A Business

    I have a big announcement to make. After a lot of soul searching, I've decided that I'm going to have a go at the whole entrepreneur thing. I've decided to turn MetaBuilders into a business. I’m just getting started here, so all the legal goop of setting up a company is still ahead of me. The coming month has some pretty big distractions for me, like the MVP summit in a week, so I don’t really know a time frame for when I’ll be making my first product announcements, but it’s definitely in the near future.

    I’m sure there’s going to be big questions about this, so I thought I’d take a second to answer some of them right now.

    What You Will See:

    • More controls on MetaBuilders, because now I’ll be able to spend all my time on this instead of balancing it with a full time job. ( YAY! )
    • Much more smooth and complete installation, help, and support systems with my controls.
    • More diverse blog posts, such as how to do the things involved in making professional level controls, such as licensing, help integration, and deployment.

    What You Won’t See:

    • You won’t see this blog become a PR/Marketing mouthpiece. Sure, I’ll probably talk some about MetaBuilders and new controls, just like I always have, but it’s going to be from a technical standpoint, and in a help-oriented vein, just like it always has been. The plan here is to have a separate MetaBuilders blog hosted on metabuilders.com for those interested getting the scoop on product news.
    • You wont see me immediately take down every free control I have available and charge for them now. Everything that’s free right now will stay free right now. Major upgrades, such as for Whidbey, will probably involve turning the more complex components into products, but not everything along these lines is set in stone yet.

    Well, all that said, it’s an exciting and slightly scary time for me right now. This whole capitalism thing is quite a ride.

  • Follow up on composite-control pattern

    I got a question on my composite-control pattern post, and I thought I'd post the answer as a blog.

    Just wondering, if you were using this with more than one Label or TextBox control, would you suggest using arrays to hold them, or creating indiviual fields?

    This question is best answered by knowing how they will be used. If you treat the controls as single entities, then make each one a private field. If you treat them as a group, then use an array. If you do  both then have both.

    For example... if you have a composite control with 3 buttons, you'll probably want three private Button fields. If you have 15 labels, and you allow the user of your control to change the text of each label, but you also want to have 1 style that changes them all... you'll probably want to have private fields but also an array containing them all. I can't really think of a scenario right now where you wouldn't want to have the private variables, but I'm sure somebody can.

    As a bit of an extension to this... If you don't know how many labels ( or whatever ) you'll have because you are generating them dynamicly... I would suggest using a Repeater instead. You get the recreation of the child controls for free when postback/viewstate comes up.

  • OneClick revisited

    I've finally gotten around to updating my OneClick control to make it work in applications where pages are served in sequence.

    The way OneClick works is by storing a token in a hidden field in the form. If the user posts twice, the token has been logged by the first post, and the OneClick.IsValid property will be false.

    Unfortunately, in the old version of OneClick, the form post tracking token was removed when the page was done processing. But this was the wrong thing to do because when pages are served in sequence, the the second, invalid, post was deemed valid because the token had been removed by the first post. Oops :)

    Anyway, if anybody using OneClick still has problems with it, let me know.

  • The Composite Control Pattern

    I've seen a a lot of people posting questions these days about composite controls. Most are having problems with viewstate. I thought I'd write up a simple example composite control so I can point at it. So here it is, a simple composite control that has a label and a textbox.

    // Composite controls should derive from WebControl and implement INamingContainer
    public class FooControl : WebControl, INamingContainer {
     // Override the getter for Controls with a call to EnsureChildControls.
     // This makes sure that your child controls always exist when they need to.
     public override ControlCollection Controls {
      get {
       EnsureChildControls();
       return base.Controls;
      }
     }
     // This is where you instantiate your child controls and set their default values.
     protected override void CreateChildControls() {
      Controls.Clear();
      myLabel = new Label();
      myLabel.ID = "myLabel";
      Controls.Add( myLabel );
      myTextBox = new TextBox();
      myTextBox.ID = "myTextBox";
      Controls.Add( myTextBox );
     }
     //These properties are delegated to the child controls.
     // As such, we call EnsureChildControls to make sure they are instantiated before accessing them.
     public String LabelText {
      get {
       EnsureChildControls();
       return myLabel.Text;
      }
      set {
       EnsureChildControls();
       myLabel.Text = value;
      }
     }
     public String TextBoxText {
      get {
       EnsureChildControls();
       return myTextBox.Text;
      }
      set {
       EnsureChildControls();
       myTextBox.Text = value;
      }
     }
     
     
     private Label myLabel;
     private TextBox myTextBox;
    }
More Posts