Solved

Mandatory properties

Posted on 2011-09-08
5
201 Views
Last Modified: 2012-08-13
Hi

I am creating a composite control. How can I force the control user to set the property.
0
Comment
Question by:KaranGupta
5 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36501484
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
 

Author Comment

by:KaranGupta
ID: 36501495
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
 
LVL 15

Accepted Solution

by:
navneethegde earned 250 total points
ID: 36501625
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
 

Author Comment

by:KaranGupta
ID: 36501633
Hi navneethegde

Thanks for the response. But I will still wait for the response from other experts
0
 
LVL 2

Assisted Solution

by:i0nutz
i0nutz earned 250 total points
ID: 36519120

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now