Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mandatory properties

Posted on 2011-09-08
5
Medium Priority
?
224 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:
Navneet earned 1000 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

610 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