0

I'm trying to achieve the two below.

 @Html.DropDownListFor(m => m.task_drop, new SelectList(ViewBag.dropList," "), new { @class = "task-drop", id = "dropping", type = "text", placeholder = "Drop the bass", data_tooltip="(this's value)" })

and this

@Html.EditorFor(m => m.task_drop2, new { @Value = Model.task_drop2, htmlAttributes = new { @class = "task-drop2", id = "task_drop2", type = "text", placeholder = "Drop the bass harder", data_tooltip="(this's value)"} })

This is so that the user will be able to see the dropdown's and the textbox's value as a dynamic tooltip when hovering over the dropdown and the textbox itself.

If there's other questions relating to this, please help me get the knowledge of it.

  1. I've already tried putting this.value inside the data-tooltip parentheses,
  2. and @value
  3. The Model.task_drop works but the tooltip will be static

I'm only interested in doing this with the use of html helpers.

I'd like it also if it's for @Html.DropDownlistFor html helper.

But any answers that will make this endeavor possible will be greatly appreciated too. Others might get the need for it :)

Thank you and have a nice day.

Hadji
  • 96
  • 6

1 Answers1

0

I've discovered a workaround and it satisfactorily works.

I've added the following script in the same view as the dropdown and the textbox.

$('.task-drop,.task-drop2').hover(function () {
       $(this).prop("title", $(this).val());
});

Friendly note: not all questions requires reprex. mygoodness.

Hadji
  • 96
  • 6
  • Your question and answer are not related in tags. You have not solved this with html helpers but with jQuery which was not tagged. Next time try to ask the question before showing code. It really looks like an X/Y problem now – mplungjan Jul 17 '19 at 08:01
  • @mplungjan "But any answers that will make this endeavor possible will be greatly appreciated too." but thank you sir. That's really informative. I'll keep it in mind the next time I ask questions. – Hadji Jul 17 '19 at 08:09