Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6943381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:08:54+00:00 2026-05-27T13:08:54+00:00

I have a form with 2 dropdownlists and a submit button. I want to

  • 0

I have a form with 2 dropdownlists and a submit button.

I want to pass the values of the lists in a URL when the list is submitted but for some reason the initial value of the ddl is getting passed.

Here’s my code:

<form runat="server">
<asp:DropDownList runat="server" ID="ddlCategory" />
<asp:DropDownList runat="server" ID="ddlLocation" />
<asp:button runat="server" ID="searchTT" OnClick="searchmyTT" Text="SEARCH" />
</form>


Sub searchmyTT(Source As Object, e As EventArgs)    
    Response.Redirect("/?cat=" & ddlCategory.SelectedItem.Value & " loc=" & ddlLocation.SelectedItem.Value)
End Sub

This ends up being redirected to /?cat=%&loc=%

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:08:55+00:00Added an answer on May 27, 2026 at 1:08 pm

    You are likely populating the DDL before the event code gets fired. When you populate its values, it will reset the selected value to the first index. Wrap your population code in something like:

     If Not IsPostBack Then
          //Populate DDL
     End If
    

    For a reference of the ASP.net lifecycle see here: http://msdn.microsoft.com/en-us/library/ms178472.aspx#lifecycle_events

    The important ones in this case are Load and Control Events (note that Load happens before your control events)

    EDIT: fix VB syntax – I’m a little rusty

    EDIT2: add reference to ASP.Net Lifecycle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have form action file in another directory but some file send to this
I have form with few buttons and I want to know what button is
I have a dropdownlist and a textbox with a button on a form. When
I have form area in my view. If I click button A , I
I have form that displays several keywords (standard set of choice lists that changes
I have form with one input for email and two submit buttons to subscribe
I have form with 1 button. when you click on the button 3 others
I want to change the value of data-confirm attribute on a button (submit) based
I know this is a basic function of the DataGridView, but for some reason,
I have a Razor page with a drop down list inside a form: @using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.