Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

best way to do this, list of urls

0 views
Skip to first unread message

Paul

unread,
Jun 6, 2008, 2:25:01 PM6/6/08
to
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

unread,
Jun 6, 2008, 2:36:01 PM6/6/08
to
(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!

Göran Andersson

unread,
Jun 6, 2008, 3:02:16 PM6/6/08
to
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

unread,
Jun 6, 2008, 3:40:01 PM6/6/08
to
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

unread,
Jun 6, 2008, 7:08:57 PM6/6/08
to
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.

0 new messages