Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indicating that attribute must be required on server control

Status
Not open for further replies.

Craftor

Programmer
Feb 1, 2001
420
NZ
Hi all

I am currently in the process of creating a server control for inclusion on a form. One of the attributes should be required. Is there any way to force this when I set up the attributes? My code for the attribute currently looks like:

Code:
[Category("Custom")]
public string ModuleID
{
	get{return _moduleID;}
	set{_moduleID= value;}
}

Thanks as always

Craftor
:cool:
 
Not sure about making it required, but could you specify a default value?
 
Hi dragonwell

Gave it a default value - that seems to be working fine for the moment. Ideally what I would like to do is have something similar happen to when you remove an element's ID attribute in the Properties window and it pops up a message box to say Component name cannot be empty.

Any ideas - please let me know :)

Thanks as always


Craftor
:cool:
 
Could you just simply check from within the property to see what the user has entered? If they have entered an incorrect value, set it to your default value?

I was reading the following MSDN article which doesn't exactly describe how to make it required but does give you a bit of information on the default value attribute:


Actually, just out of interest, I wonder what would happen if you used messagebox.show from within the property in the MSDN example?



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
ca8msm - I like your idea - I think that is the way I am going to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top