C# Adding title attribute to SelectListItem

This code is from a MVC4 project using Razor. No Razor shown here though.

var serverListModel = new ServerList();
var dismissedList = from String[] v in ldbh.getAllDismissedServers() orderby v[1] select v;
serverListModel.DropDownItemsDismissedNodes.Clear();
foreach (String[] v in dismissedList) {
    String title = "Stop date: " + v[2] + " End date: " + v[3];
    serverListModel.DropDownItemsDismissedNodes.Add(new SelectListItem { Text = v[1], Value = v[0] });
}

Open in new window


SelectListItem only accepts Text, Value and Selected. What if I want to add an attribute Title? I can do that with jQuery if I wanted and see it work, but I would prefer it done from the server side.
LVL 2
itniflAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
SelectListItems get translated into <option> elements of a <select> upon rendering. <option> elements don't contain title attributes, which is why you don't have anything available to you on the server side. If you are setting a title for the purpose of having a tooltip, then I don't believe this functionality will work cross-browser, and that Javascript will be your only recourse.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itniflAuthor Commented:
I used jQuery and Javascript to get things done. Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.