• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 86
  • Last Modified:

adding id tag to mvc dropdownlist

I'm using MVC 5 in a ASP.NET MVC application.

In my view I'm called my model like this at the beginning of the page.

@model Northwind.Models.EmployeeModel

Then on my page I have a dropdown list that looks like this:

@Html.DropDownList("LastName")

When I run my page it works fine.

So here's my question.

When I use a html dropdownlist the typical tag looks like this:

<input id="DDLLastName" type="text" class="DDLLastNameStyle"  />


How do i add id tag called the following id="DDLLastName"  to my which mvc dropdownlist which currently looks like this?:

@Html.DropDownList("LastName")
0
maqskywalker
Asked:
maqskywalker
1 Solution
 
Lokesh B RDeveloperCommented:
Hi,

try

@Html.DropDownList("LastName", null, new { @id = "DDLLastName", @class = "DDLLastNameStyle" });

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now