Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > I guess this can't be done can it ?

Reply
Thread Tools

I guess this can't be done can it ?

 
 
Paul D. Fox
Guest
Posts: n/a
 
      07-01-2005
I guess this can't be done can it ?

1. Create a web user control (.ascx page) with just a Drop-down control in
it.
2. Drag the user control to your web form (.aspx page)
3. Access the drop-down's selectedValue (to save to a Database) or Set the
selectedValue of the drop-down from a
Database query

P


 
Reply With Quote
 
 
 
 
cc
Guest
Posts: n/a
 
      07-01-2005
Sure it can. Not sure about the drag-and-drop, but click the Html
button and get into the code-side of the presentation page. Make sure
to put an @Register page directive at the top to register your user
control (for more info, google "ASP.Net User Controls"--MSDN has a page
explaining how to properly insert the tag.)
Personally, I like to expose only the properties of the user control's
sub-controls (in your case, the drop-down control) that I'm going to
use, via a property in the code-behind. It just makes things cleaner.
For a quick-and-dirty approach, however, change the access modifier for
the drop-down control in the user-control's code-behind (.ascx.cs or
..ascx.vb file, depending on which language you're using) from
"protected" (if C#; or "Friend" if VB) to "public". If you dragged your
drop-down list onto your .ascx page, you should see your drop-down
control defined near the top of the page. It'll probably be something
like DropDownList1. Once you've change the access modifier to public,
you should be able to see the control in your aspx page's code-behind
file (e.g. myUserControl.DropDownList1.) You'll be able to access all
of the properties of the drop-down control as if you were working with
it in the .ascx page.

 
Reply With Quote
 
 
 
 
Steve Walker
Guest
Posts: n/a
 
      07-02-2005
In message <>, Paul D. Fox
<> writes
>I guess this can't be done can it ?
>
>1. Create a web user control (.ascx page) with just a Drop-down control in
>it.
>2. Drag the user control to your web form (.aspx page)
>3. Access the drop-down's selectedValue (to save to a Database) or Set the
>selectedValue of the drop-down from a
>Database query


I'd do that either by subclassing System.Web.UI.WebControls.DropDownList
or by building a composite control. It's very simple and easy to do, and
it works properly at design-time. I hardly ever bother with web user
controls.

--
Steve Walker
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you guess what it will be happened? Jun Young Kim Ruby 9 01-08-2009 11:53 AM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 32 08-27-2004 07:21 AM
I asked before and was told it could not be done, well its Done...?? Karen Parker NZ Computing 7 08-26-2004 02:25 AM
How to let browsers be done when parent is done and not wait for childrn's finishing in CGI Zhidian Du Perl Misc 0 02-21-2004 07:01 PM
Can you guess the focal length? George Preddy Digital Photography 11 11-15-2003 07:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57