473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

c# Custom control properties

Hi,

Can any body help me adding properties to my web control. In my control I want a property and with that property I need its default values like value1,value2,value3.

Please let me know how to add such a property and how to add default values to it.


How can I do that. I have more than 10 controls in my web control. Can any one have any idea how to do this ?
Apr 19 '07 #1
3 2593
Frinavale
9,735 Expert Mod 8TB
Hi,

Can any body help me adding properties to my web control. In my control I want a property and with that property I need its default values like value1,value2,value3.

Please let me know how to add such a property and how to add default values to it.


How can I do that. I have more than 10 controls in my web control. Can any one have any idea how to do this ?
Hi! Welcome to theScripts!

Just like you have public and private variables in your user controls, you can have public and private Properties.

For example:
Expand|Select|Wrap|Line Numbers
  1.  Partial Class myCustomUserControl
  2.         Inherits System.Web.UI.UserControl
  3.      ...
  4.  
  5.      Private var1
  6.      Private var2
  7.  
  8.      Public Property  Var1sProperty()
  9.           Get
  10.              return var1
  11.           End Get
  12.           Set (ByVal value)
  13.               var1=value
  14.           End Set
  15.        End Property
  16.  
  17. ...
  18.  
  19.         Private Sub.....
  20.  
  21. End Class
  22.  
  23.  
Hope this was helpful! :)

-Frinny
Apr 19 '07 #2
Ya that is fine. Let me give me some more details.
I am developing a payment user control which can be used in any application.
I have two variables with their predefined values

And want to give them to be set by the coder who is developing a specific payment system.

So on my ascx page I have card type , card number , security code and expiration date.

along with that i need two properties which can be settled according to the application.

What should i do ?


Hi! Welcome to theScripts!

Just like you have public and private variables in your user controls, you can have public and private Properties.

For example:
Expand|Select|Wrap|Line Numbers
  1.  Partial Class myCustomUserControl
  2.         Inherits System.Web.UI.UserControl
  3.      ...
  4.  
  5.      Private var1
  6.      Private var2
  7.  
  8.      Public Property  Var1sProperty()
  9.           Get
  10.              return var1
  11.           End Get
  12.           Set (ByVal value)
  13.               var1=value
  14.           End Set
  15.        End Property
  16.  
  17. ...
  18.  
  19.         Private Sub.....
  20.  
  21. End Class
  22.  
  23.  



Hope this was helpful! :)

-Frinny
Apr 20 '07 #3
Frinavale
9,735 Expert Mod 8TB
Ya that is fine. Let me give me some more details.
I am developing a payment user control which can be used in any application.
I have two variables with their predefined values

And want to give them to be set by the coder who is developing a specific payment system.

So on my ascx page I have card type , card number , security code and expiration date.

along with that i need two properties which can be settled according to the application.

What should i do ?
Make your card number , security code and expiration date variables private so that they are not accessible from the outside.

Define the to properties that can be settled according to the application using Public properties.

Public properties allow other applications to access variables inside your control.

The other programmer would create an instance of your control and then would have access to the public properties.
Apr 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Steve Amey | last post by:
Hi all I am creating a basic control to perform some tasks, and I want to declare some events to be raised so they can be handled from the form that the control is on. I can create my own Event...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
3
by: Eric Sabine | last post by:
I've created a custom control (ascx) which contains a tree view, a drop down list, and a listbox. The custom control is included in a web form and at runtime, won't compile (I get the...
1
by: chambersdon | last post by:
How do I get the public properties of my custom control to show in the designer. The properties are all Strings but they do not show up in the designer property window. My custom control...
9
by: PJ6 | last post by:
I'm sure it's some attribute I have to set but I can't find it. I'd like to be able to have my properties in my custom web user controls show up in the web forms designer. Is that possible? Paul
4
by: Antuane | last post by:
i'm trying to create a custom textbox class, by simply creating a new class & inheriting from the textbox class. But i don't have a UI of this class. I.e., how can i set up the default text, color...
0
by: Pavan | last post by:
My name is Pavan and I am a software engineer working on ASP .Net web development. Currently I am using .Net 2.0 Professional Edition to develop my web pages. I have a problem
0
by: Julien | last post by:
Hi ! I'm creating a custom control, in which I would render an image with client-side script code to display/hide a calendar control which also belong to my custom control. In this control I've...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a collection property named "Columns". this collection property add/remove column objects. in my Column class i have a property named Alignment...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.