best way to do this, list of urls

Discussion in 'ASP .Net' started by Paul, Jun 6, 2008.

  1. Paul

    Paul Guest

    I have a web app that allows the user to create a list of urls. I am
    currently have a textbox the user inputs the URL in one at a time and then a
    button that when clicked adds the link to a dropdown list. Then for the
    dropdown selected event I set the URL of a link button to the selected value
    in the list.
    Just wondering if you can have a dropdown list of hyperlinks? thanks!
    --
    Paul G
    Software engineer.
    Paul, Jun 6, 2008
    #1
    1. Advertising

  2. (no cop-out intended here)
    see the AJAX tool kit on asp.net this may give you options with out a lot of
    work
    --
    Share The Knowledge. I need all the help I can get and so do you!


    "Paul" wrote:

    > I have a web app that allows the user to create a list of urls. I am
    > currently have a textbox the user inputs the URL in one at a time and then a
    > button that when clicked adds the link to a dropdown list. Then for the
    > dropdown selected event I set the URL of a link button to the selected value
    > in the list.
    > Just wondering if you can have a dropdown list of hyperlinks? thanks!
    > --
    > Paul G
    > Software engineer.
    Yankee Imperialist Dog, Jun 6, 2008
    #2
    1. Advertising

  3. Paul wrote:
    > Just wondering if you can have a dropdown list of hyperlinks? thanks!


    No, you can't, but you can easily make the dropdown go to the selected
    url (without even having to do another postback). Just add an onchange
    event to the dropdown:

    theDropdown.Attributes.Add("onchange",
    "window.location=this.options[this.selectedIndex].value;");

    --
    Göran Andersson
    _____
    http://www.guffa.com
    Göran Andersson, Jun 6, 2008
    #3
  4. Paul

    Paul Guest

    thanks for the information. I did not see an onchange event from the event
    property box of the dropdown but did find a TextChanged event. I added the
    code below and set a break point. It does hit the break point but looks like
    it is not going to the page, possibly a bad URL or should this work?

    protected void drdn_links_TextChanged(object sender, EventArgs e)
    {
    this.drdn_links.Attributes.Add("onchange",
    "window.location=this.options[this.selectedIndex].value;");
    }
    --
    Paul G
    Software engineer.


    "Göran Andersson" wrote:

    > Paul wrote:
    > > Just wondering if you can have a dropdown list of hyperlinks? thanks!

    >
    > No, you can't, but you can easily make the dropdown go to the selected
    > url (without even having to do another postback). Just add an onchange
    > event to the dropdown:
    >
    > theDropdown.Attributes.Add("onchange",
    > "window.location=this.options[this.selectedIndex].value;");
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
    >
    Paul, Jun 6, 2008
    #4
  5. Paul wrote:
    > thanks for the information. I did not see an onchange event from the event
    > property box of the dropdown


    That's because it's not a server event. I said that it didn't do a postback.

    > but did find a TextChanged event. I added the
    > code below and set a break point. It does hit the break point but looks like
    > it is not going to the page, possibly a bad URL or should this work?
    >
    > protected void drdn_links_TextChanged(object sender, EventArgs e)
    > {
    > this.drdn_links.Attributes.Add("onchange",
    > "window.location=this.options[this.selectedIndex].value;");
    > }


    You should not put the code in an event handler. The code adds a client
    event to the control, so if you do it in an event handler, it will work
    the second time that you change the dropdown.

    Put the code in Page_Load.

    --
    Göran Andersson
    _____
    http://www.guffa.com
    Göran Andersson, Jun 7, 2008
    #5
    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. Kaidi
    Replies:
    5
    Views:
    449
    Andrew Thompson
    Jan 4, 2004
  2. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    723
    Sriram Srivatsan
    Aug 12, 2008
  3. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,075
    Adam Monsen
    Feb 8, 2009
  4. Angus
    Replies:
    6
    Views:
    1,606
    James Kanze
    Jan 23, 2010
  5. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    265
    Steve T.
    Mar 4, 2004
Loading...

Share This Page