Kaan Öztürk
Kaan Öztürk

Reputation: 442

Call SelectListItem in class library

I have a class library in solution. There are models and repositories and I want to create static list in class library to use in project. one of the static lists must return a list of data in "SelectListItem" type

   public class StaticLists
    {
        public List<SelectListItem> IsletmeTipleri()
        {
           return null
        }
    }

But I'm getting error;

The type or namespace name 'SelectListItem' could not be found.

I should call 'using System.Web.Mvc' to use SelectListItem but I can't call in class library.

Can I call SelectListItem in class library? How do I do if I can call ?

Upvotes: 0

Views: 1390

Answers (2)

Manuel Basiri
Manuel Basiri

Reputation: 93

This is not a recommended practice. Select List elements and the MVC is a presentation layer component. You must translate your select lists to a different object like a dictionary before sending to a class library and perform a reverse translation whenever you want to show that information in your presentation layer in form of a select list.

Upvotes: 0

Saineshwar Bageri - MVP
Saineshwar Bageri - MVP

Reputation: 4031

Add Reference of System.Web.Mvc.dll to you Class Libary project.

Reference of System.Web.Mvc

Upvotes: 1

Related Questions