문제

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.

도움이 되었습니까?

해결책

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

다른 팁

Also, you can write in htmlAttributes object like that

@multiple="multiple" 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top