Jump to content

Custom Controls

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
Alright guys, I've got another situation I need some help with. I've never dealt with custom controls before and now is the time to start. I need to create a custom control that produces a rectangle. The background color of this rectangle should depend on a Boolean value corresponding to "on" and "off". So when the variable is true, I want it to be one color, when it's false, I'd like to to be another color. I want the "user" to be able to choose the color. So I'm assuming that those colors should be stored as properties. Here's an example of what I want...

"When the system is on, the text should say "on", on a green background. When the system is off, the text should say "off" on a red background."

I want all text and colors to be properties so the developer can set them at design time.

I need some help with this guys. I don't know a whole lot about custom controls. I know you can make your own properties, but I don't even really know how to do that. I'm also not so great with Boolean values, i'm still a beginner programmer. If everyone could help me out, that'd be great. Thank you. If you have any questions, just post and ask. Thanks.

#2
sumanth7975

sumanth7975

    Newbie

  • Members
  • Pip
  • 1 posts
Hi,
I would use a user control.
Set private properties and then put get set's for it

private int rectWidth = 0;

public int RectWidth{
get{rectWidth;}
set{rectWidth = value;}
}
}

Now this RectWidth will be visible via intellisense on all aspx pages where you place the user control. This way the values can be set by developers during design time and they do not need to know how you are handling those values. Ofcourse, you need to do something with these values in your user control to make it appear the way you like it to be.

Good luck.

Edited by Jaan, 06 November 2008 - 10:33 PM.
Please use code tags when you're posting your codes!


#3
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
You can draw your own controls.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#4
Xystus777

Xystus777

    Learning Programmer

  • Members
  • PipPipPip
  • 59 posts
I figured it out. I needed it to be done all programmatically, but it's all good now. Thank you guys!

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Uh, welcome.
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums