Liam
Liam

Reputation: 9855

Link to Anchor tag with .net dropdownlist

im working on a website thats built using .net.

Theres a dropdown on my page that when an option is selected ther page refreshes, what I need though is for the page to refresh and link to an anchor further down my page "#company-detail"

<asp:DropDownList ID="DDL_Companies" runat="server" CssClass="selectd" onselectedindexchanged="DDL_Companies_SelectedIndexChanged" AutoPostBack="true">
    <asp:ListItem>Select a partner...</asp:ListItem>
    <asp:ListItem>opt</asp:ListItem>
    <asp:ListItem>opt</asp:ListItem>
    <asp:ListItem>opt</asp:ListItem>
    <asp:ListItem>opt</asp:ListItem>
    <asp:ListItem>opt</asp:ListItem>
</asp:DropDownList>

Upvotes: 0

Views: 767

Answers (2)

pilavust
pilavust

Reputation: 538

You can reload page when select an item like this: Response.Redirect("yourHost.aspx#company-detail")

Upvotes: 1

Martin
Martin

Reputation: 1536

You can solve this with javascript instead of roundtrip to the server. remove the AutoPostBack=true then add an onchange() event to the rendered select element. Do your navigation to the url there

EDIT: Sorry, didn't see your requirement for the page to refresh. I guess you can, on the roundtrip to the server, add a RegisterClientScriptBlock so that the navigation the page section happens on the client side after the refresh. This will preserve the values on the page, instead of a response.redirect server side http://msdn.microsoft.com/en-us/library/bahh2fef.aspx

Upvotes: 1

Related Questions