仍在學習MVC3,EF和Razor,我想知道是否有人已成功使用Colorbox來增強MVC3的圖庫,並很樂意爲我伸出援助之手。我已經設置了一個畫廊模型,控制器和視圖。我將圖像保存在Content文件夾的圖像文件夾中。我從大圖像文件中動態生成縮略圖。我有在圖庫的索引視圖中引用的colorbox javascripts和css和jquery。單擊縮略圖時,會顯示空白的黑色屏幕。任何幫助將不勝感激。在MVC3中使用Colorbox設置圖庫
索引視圖是在視圖頁面底部如下
@using CPS.Helpers;
@foreach (var item in Model)
{
<a href="Content/Images/@item.GalleryFileLink" rel="gal"> @Html.Image("Content/Images/" +item.GalleryFileLink + "?width=130&height=98", item.GalleryText)</a>`
我有這個 <script type="text/javascript"> $(document).ready(function() { $(".gallery_module").colorbox({rel: 'gal' }); }); </script>
我使用的圖片助手是如下
public static class MyHelper{
public static MvcHtmlString Image(this HtmlHelper helper, string src, string altText)
{
var url = new UrlHelper(helper.ViewContext.RequestContext);
var builder = new TagBuilder("img");
builder.MergeAttribute("src", url.Content(src));
builder.MergeAttribute("alt", altText);
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}}
縮略圖在查看頁面顯示正常,但是當縮略圖被點擊時,黑色空白屏幕結果爲
您想要顯示的任何代碼? – 2012-01-11 06:54:31
@DarinDimitrov我已添加代碼。我想知道的是,colorbox是否可以在沒有任何調整的情況下使用MVC? – Diin 2012-01-11 21:17:48
@Diin不要擔心colorbox與MVC一起使用的特殊調整,它只是一些js和css ... – Draganov 2012-01-12 03:14:45