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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reusable Code

Status
Not open for further replies.

jjmendo

Programmer
Feb 7, 2005
7
US
I'm createing a web form and have a dropdownlist. the dropdownlist lists all the states. I would be placing this dropdownlist in several different pages. I'm unsure as to how to create a class for the dropdownlist code to be reused. I've always placed the code in the codebehind and haven't created any classes. Could someone help as to how I would create the class and call it from the aspx page.
Thanx.
 
There's two approaches you can take:

1. Write a class in another assembly that you can reuse, that accepts a ListBox and populates it with your list of states. Call it from your code-behind by using the new operator on it (like any other class).

2. Create a custom ASP.NET control that is a state/province picker. You'll want a book like "ASP.NET Server Controls and Components" from Microsoft Press. This is much more difficult, but you gain a control that you can put in your toolbox and reuse just by dragging it onto your form.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top