When its giving an error saying AppHelper does not exist, am I missing any reference?
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/S开发者_Python百科hared/Site.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<DocumentsController.ViewDetails>" %>
<%@ Import Namespace="DocuvaultMVC.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Document View
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Notes</h2>
<% Html.RenderPartial("~/Views/Shared/UserControl/Notes.ascx",Model.Notes); %>
<br />
<h2>User Tracking Informtaion</h2>
<% Html.RenderPartial("~/Views/Shared/UserControl/Tracking.ascx",Model.Log); %>
<div>
<% for (int i = 1; i <= ViewData.Model.Pages; i++)
{ %>
<br />
<img src="<%=AppHelper.PDFUrl(ViewData.Model.DocumentId,i)%>" alt="Document" width="612" height="792" />
<%}%>
<div>
</div>
</div>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
namespace DocuvaultMVC.Helpers
{
public static class AppHelper
{
/// <summary>
/// Builds a Script url
/// </summary>
/// <param name="cssFile">The name of the CSS file</param>
public static string ScriptUrl(string script)
{
return VirtualPathUtility.ToAbsolute("~/scripts/" + script);
}
public static string PDFUrl(int id, int page)
{
return VirtualPathUtility.ToAbsolute("~/Documents/ViewDocument.aspx/" + id + "/" + page);
}
}
}
Try
<%=DocuvaultMVC.Helpers.AppHelper.PDFUrl(ViewData.Model.DocumentId,i)%>
Yes - you need to reference helper, so its something like:
<%@ Import Namespace="DocuvaultMVC.Helpers" %>
at the top of you view. Alternatively you can put this in your web.config.
精彩评论