Hamid Reza
Hamid Reza

Reputation: 2973

How to set mulipart attributes for html helpers?

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.

Upvotes: 0

Views: 2948

Answers (2)

bashkan
bashkan

Reputation: 464

Also, you can write in htmlAttributes object like that

@multiple="multiple" 

Upvotes: 0

Dai
Dai

Reputation: 155250

"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">

Upvotes: 2

Related Questions