Domanda

I want to set a multipart attribute for a html.Dropdownlist. How to do this?

@Html.DropDownList("ProductTypesId",DropdownHelper.GetAllProductTypes("-1"), new { @class="selectpicker", multiple title = "Select One" })

But I have error for the multiple title attribute.

Update

The error is:

The name multiple doesn't exist in the current context.

È stato utile?

Soluzione

"multiple title" is not an attribute in HTML. Attributes are space-separated.

What you have is a single-label attribute "multiple" and the second attribute "title="Select one"

HTML allows for single-label attributes to have their name as a value - this has the same effect and is how XHTML supports single-label attributes, like so:

new { @class="selectpicker", multiple="multiple" title="Select One" }

this will be rendered like this:

<select class="select picker" multiple="multiple" title="Select One">

Altri suggerimenti

Also, you can write in htmlAttributes object like that

@multiple="multiple" 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top