Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • djscorch 67 posts 106 karma points
    May 09, 2012 @ 14:21
    djscorch
    0

    Getting a dropdownlist selected value

    Hi,

    I've created a dropdown list in a macro using @Html.DropDownList

    I want to append the selected value to the querystring, is there an easy way of accessing this?

     

  • gilad 185 posts 425 karma points
    May 09, 2012 @ 14:26
    gilad
    0

    Hi Djscorch.

    What are you exactly trying to do?

    What should happen after change the dropdown?

     

  • djscorch 67 posts 106 karma points
    May 09, 2012 @ 14:32
    djscorch
    0

    Nothing should happen after the dropdown changes, but there is a button under the ddl, when they hit this i want to send them to another page with the selected value added to the querystring.

  • gilad 185 posts 425 karma points
    May 09, 2012 @ 14:49
    gilad
    0

    Hi Djsorch.

    The razor / macro using to render the page when page load.

    Try reading more basic stuff like this : http://www.w3schools.com/html/html_forms.asp

    after sending the value you can get it in macro with :

    @{

    string fromRequst =  Request["key"];

    }

  • Dan Lister 416 posts 1974 karma points c-trib
    May 09, 2012 @ 14:54
    Dan Lister
    0

    Hi djscorch,

    You could wrap your drop down list in a form and set the forms action to 'get' in order for it to be passed via query string.

    @using (Html.BeginForm("Action", "Controller", null, FormMethod.Get))
    {
    @Html.DropDownList() 
    <input type="submit" />

    Dan. 

  • djscorch 67 posts 106 karma points
    May 09, 2012 @ 16:57
    djscorch
    0

    Took it back to the old school and used a POST method.

    Don't know why I thought I could simply just get at the selected value! (I was thinking webforms postback)

Please Sign in or register to post replies

Write your reply to:

Draft