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.
Custom Controls
Started by Xystus777, Nov 06 2008 06:08 AM
4 replies to this topic
#1
Posted 06 November 2008 - 06:08 AM
|
|
|
#2
Posted 06 November 2008 - 11:33 AM
Hi,
I would use a user control.
Set private properties and then put get set's for it
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.
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!
#4
Posted 10 November 2008 - 07:31 AM
I figured it out. I needed it to be done all programmatically, but it's all good now. Thank you guys!


Sign In
Create Account


Back to top









