2016-11-27 72 views
0

我有一个使用MVC 5创建的项目,这些视图是基于html剃刀a,Javascript和Jquery创建的。如何在MVC剃刀视图中显示颜色选择器

我的一个用于插入数据的视图,包含一个文本框,我希望它显示颜色选择器,如果用户点击它。

我试过使用这个库jscolor.js,但它在纯HTML页面中工作,我未能使其在剃刀视图中工作,我不知道为什么。

<!DOCTYPE html> 
<html> 
<head> 
    <title>jscolor Example</title> 
</head> 
<body style="text-align:center;"> 
    <script src="jscolor.js"></script> 
    <h2>Example 1</h2> 
    Color: <input class="jscolor" value="ab2567"> 
</body> 
</html> 

的链接,Javascript库http://jscolor.com/

,这里是在MVC视图

<script src="jscolor.js"></script> 

<script> 
    $(document).ready(function() { 
     jscolor.installByClassName("jscolor"); 
    }); 
</script> 

@using (Html.BeginForm("Create, "DateField", FormMethod.Post)) 
{ 
    <input class="jscolor" value="ab2567"/> 
....etc 

任何代码有这方面的信息?

+0

你试过什么样的剃须刀代码? –

+0

@ Html.TexBoxFor(m => m.color,new {@ class =“jscolor”}) – Laila

+0

那么你有什么问题? –

回答

0

请尝试下面的代码。它为我工作。

@Html.TextBoxFor(m => m.PropertyList.color, new { @class = "jscolor"})