locked
Cant get drop down list value RRS feed

  • Question

  • User-859912054 posted

    Hi

    I can't get values from the drop-down menu.
    The code:

    <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem Value="value" Selected="False">  
          Available Captions
            </asp:ListItem>
    </asp:DropDownList

    Dim lang As String = DropDownList1.SelectedValue

    This cause to getting invaled url and getting a 400 error and xml exception
     
    I can't track the error because the code works in some places.
    The code works here (a blank page with user control) and here (user control inside an update panel)
    But it doesn't work here (user control inside an update panel) and I get "value" as value

    (whene click red play arrow button to get youtube caption)
    How I can fix or track this error

    Thank

    Monday, August 5, 2019 9:47 AM

Answers

  • User-859912054 posted

    Thank you for your answer i fix the problem by enable  view state 

    UserCtrl.EnableViewState = True;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 11:45 AM

All replies

  • User-1038772411 posted

    Hello, Yusuf_A

    You have to use selecteditem.value instead of selectedvalue

    dropdownlistname.SelectedItem.Value

    And Use IsPostback event also.

    Refer Link :

    https://stackoverflow.com/questions/12834190/why-cant-get-the-right-value-of-dropdownlist-in-asp-net

    Thanks.

    Monday, August 5, 2019 10:29 AM
  • User288213138 posted

    Hi Yusuf_A,

    Based on your description and the link , I cannot reproduce your problem.

    400 error means that bad request. the server cannot or will not process the request due to a significant client error (for example, a malformed request syntax, too large size, invalid request message, or spoofed routing request).

    More information about 400 error you can refere to this link:https://airbrake.io/blog/http-errors/400-bad-request

    If you haven't solved the problem yet, please post you code that can reprodece your problem.

    Best regards,

    Sam

    Tuesday, August 6, 2019 3:04 AM
  • User-859912054 posted

    Thank you for your answer i fix the problem by enable  view state 

    UserCtrl.EnableViewState = True;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 6, 2019 11:45 AM