1

I couldnt find an attribute "title" for DropdownListFor and was wondering how to do the same for just the selected item in the dropdownlistFor. My code is

               @Html.DropDownListFor(m => m.objDetails.CategoryId, new SelectList(Model.objDetails.Categories, "CategoryId", "CategoryName"),  new { id = "cboCategory", style = "width:340px;"} )

1 Answer 1

1

Source SO

The built-in DropDownList helper doesn't allow you for setting additional HTML attributes on individual options such as title. You will have to write your own custom helper if you want to achieve that. Here's one example

Sign up to request clarification or add additional context in comments.

1 Comment

hmmm... Maybe i could keep something lyk a span or div inside dropdownlist, set the value as selctedindex and and provide title for the div.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.