• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Mandatory properties

Hi

I am creating a composite control. How can I force the control user to set the property.
0
KaranGupta
Asked:
KaranGupta
2 Solutions
 
Pratima PharandeCommented:
do ypu mean to say you want to add validation in composit control

refer this links

http://forums.asp.net/t/1325623.aspx/1
http://stackoverflow.com/questions/1206384/asp-net-customvalidator-in-a-compositecontrol
0
 
KaranGuptaAuthor Commented:
Hi pratima_mcs

Thanks for the response. Let me give you a scenario for example I have created a property MyControlId. This property is for setting the ID of the control. But if the property is not declared then the value of this property would be null and certain logic can fail. So I want a mandatory property to which if the user won't declare project will give compile time error.

I hope I am clear

Regards
Karan Gupta
0
 
NavneetCommented:
Hi!

No you can't force, want you can do is in case of empty or wrong property
You need to assign or set default property value.

Thanks!
0
 
KaranGuptaAuthor Commented:
Hi navneethegde

Thanks for the response. But I will still wait for the response from other experts
0
 
i0nutzCommented:

If you are creating a composite control and you have a property ID (you should have such a property), the  best practice is to request for the client of you control to provide the ID throw your control's constructor. I don't have to say more, this is a basic concept when creating controls in ASP.
If you have more properties for your control that are required, you should use client & server validators.

Hope this will help you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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