I guess this can't be done can it ?

Discussion in 'ASP .Net Web Controls' started by Paul D. Fox, Jul 1, 2005.

  1. Paul D. Fox

    Paul D. Fox Guest

    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
     
    Paul D. Fox, Jul 1, 2005
    #1
    1. Advertising

  2. Paul D. Fox

    cc Guest

    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.
     
    cc, Jul 1, 2005
    #2
    1. Advertising

  3. Paul D. Fox

    Steve Walker Guest

    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
     
    Steve Walker, Jul 2, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    5,612
  2. Jim in Arizona

    Guess What ...

    Jim in Arizona, Jan 31, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    477
    Juan T. Llibre
    Jan 31, 2006
  3. Ashanen

    I guess what I'm asking is....

    Ashanen, Jan 2, 2004, in forum: Java
    Replies:
    6
    Views:
    422
    Ashanen
    Jan 3, 2004
  4. Jun Young Kim

    Can you guess what it will be happened?

    Jun Young Kim, Jan 8, 2009, in forum: Ruby
    Replies:
    9
    Views:
    116
    Jun Young Kim
    Jan 8, 2009
  5. Zhidian Du
    Replies:
    0
    Views:
    174
    Zhidian Du
    Feb 21, 2004
Loading...

Share This Page