Solved

Mandatory properties

Posted on 2011-09-08
5
209 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

790 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