Get input value

Last post 10-29-2008 10:51 PM by levib. 1 replies.

Sort Posts:

  • Get input value

    10-29-2008, 9:34 PM
    • Contributor
      3,569 point Contributor
    • shapper
    • Member since 11-28-2004, 9:15 PM
    • Posts 2,949

    Hello,

    On a view I am creating List Items on an Unordered list, using JQuery, which is inside a form. Each item is as follows:

    <form ...
      <ul>
        <li>Book<input type="hidden" value="Book" name="Themes"/></li>
        <li>Video<input type="hidden" value="Video" name="Themes"/></li>
      ...
    </form>  

    The inputs are created so the values Book and Video can be created on the controller.

    On the controller I am able to get the values of all form elements but when I try to get the values of Themes using:

          string[] themes = new string[] {};
          UpdateModel(themes, new[] { "Themes" });  

    I get the following error, on code line 2:

      "Value cannot be null or empty."

    I tried everything I could think of but no luck.

    Could someone please help me out?

    Thanks,

    Miguel

  • Re: Get input value

    10-29-2008, 10:51 PM
    • Contributor
      4,651 point Contributor
    • levib
    • Member since 07-23-2007, 7:50 PM
    • Redmond, WA
    • Posts 796
    • AspNetTeam

    Since arrays are of fixed size once created, the UpdateModel() method can't modify a zero-length array.  Instead, your action method should just have a parameter named themes of type string[], and it should work just fine.

Page 1 of 1 (2 items)