Solved

Mandatory properties

Posted on 2011-09-08
5
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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