jQuery UI Widgets Forums Lists DropDownList Request.Form["?????"]

This topic contains 3 replies, has 2 voices, and was last updated by  Justintkw 8 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Request.Form["?????"] #83310

    Justintkw
    Participant

    Hi:

    There must be a simple answer to this, but I can’t find it anywhere. . . I have placed the dropdownlist on my MVC5 form and loaded it with data. The div tag has the id of “TheDropDown”. When I look at the page source, I can see any <select> element with the id of “TheDropDown.” When I submit the form and try to get the select value of the dropdownlist by using Request.Form[“TheDropDown”].ToString(), I get an error of null exception.

    So, my qustion is: Isn’t there a simple way to pass the selected value from a jQWidget dropdownlist to MVC’s controller like any other form control??? Or MUST I go through JQuery?

    Thanks,

    Justin

    Request.Form["?????"] #83312

    Peter Stoev
    Keymaster

    Hi Justin,

    Set the “name” attribute of the DIV tag. This is actually demonstrated in our ASP .NET MVC demos: http://www.jqwidgets.com/jquery-widgets-demo/demos/aspnetmvc/index.htm

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Request.Form["?????"] #83671

    Justintkw
    Participant

    Hi Peter:

    I read over that intro page. I can’t see anywhere that setting the “name” attribute was mentioned. The example itself only uses id, and I saw no postback example included.

    At any rate, I did add the name attribute to the div tag for the dropdownlist. But during postback, Request.Form still does NOT contain that particular key. It contains only keys of the other controls.

    <div id="jqxCombo_OffCampusInst" name="jqxCombo_OffCampusInst">

    controller:
    string OffCampusOrgID = Request.Form[“jqxCombo_OffCampusInst”].ToString(); generates error: Object reference not set to an instance of an object.

    Request.Form["?????"] #83672

    Justintkw
    Participant

    OKay. Found out the issue: I had the combobox disabled in the view, and the control is therefore not passed to the controller. Is that by design? Is that no way to disable the control in the view, and still have the value accessible by the controller?

    Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.