I have tried many many times to google this but trying to google overflow problem ie in google is like googling what is the meaning of life you get lots of different answers to different problems but no one has exactly the answer you want!

I have an editor template in my mvc site which creates a listbox in a table with some other fields and buttons. So my problem is that the listbox doesn't show the scrollbars when the value inside is too long. The value is added to the listbox when the user adds a key and value and clicks add

<tr>
    <td>

        @Html.TextBox("New Key", newKey, new {id = "keytext", placeholder = "Parmeter Key", @class = "form-control", style = "width: 133px;"})
        @Html.TextBox("New Value", newValue, new {id = "valuetext", placeholder = "Parmeter Value", @class = "form-control", style = "width: 133px;"})

        <div id="hiddensq">

        </div>
        @for (int i = 0; i < Model.Count(); i++)
        {
            @Html.Hidden("UserValues", Model.ToList()[i].ToString())
        }
    </td>
    <td rowspan="2">
        @Html.ListBox("ListBox", new SelectList(Model), new { id = "listBox", onclick = "editSelected(this.value)", size = 6, @class = "form-control", style = "width: 144px; height: 105px; overflow: auto;" })
    </td>
</tr>
<tr>
    <td>
        <input type="button" value="Add" class="btn btn-default" onclick="add(this.value)" />
        <input type="button" value="Remove" class="btn btn-default" onclick="removeFromListbox(this.value)" />
    </td>
</tr>

My Model contains a list of an object I have made called Parameter

        public List<Parameter> Parameters { get; set; }

This stores the values in the listbox. Inside parameters theres just simply 2 properties and an overridden toString

    public string Key { get; set; }
    public string Value { get; set; }

    public override string ToString()
    {
        return Key + "=" + Value;
    }

I have tried soo many different solutions that I have tried on the web but none of them work. It may be because I am new to all of this and have been thrown in the deep end (seems to be a common problem for me) but I would just like to sort this out so I can move on.

Related posts

Recent Viewed