aspx页面中的.dll问题

时间:2010-03-24 14:07:54

标签: asp.net-3.5

我已将一个程序集添加到项目中,然后按如下方式使用程序集:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Global.Master" AutoEventWireup="true" CodeBehind="Calendar.aspx.cs" Inherits="Permias.Calendar" %>
<%@ Register TagPrefix="ec" Namespace="ControlSample" Assembly="EventCalendar" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="content">
            <div class="post">
                <ec:EventCalendar runat="server" ID="eventscalendar" DataSourceID="sqldatasource1"
                BorderWidth="0" DayField="starttime" ShowTitle="true" CssClass="eventmonthtable">
                <DayHeaderStyle CssClass="caldays" />
                <DayStyle CssClass="calcurrentmonth" />
                <TodayDayStyle CssClass="calcurrentday" />
                <WeekendDayStyle CssClass="calweekend" />
                <OtherMonthDayStyle CssClass="calothermonth" />
                <DayNumberStyle CssClass="dayNumber" />
                <HeaderTemplate>
                    <table width="100%">
                        <tr align="center">
                            <td>
                                <asp:LinkButton ID="PrevMonth" runat="server" Text='<%# "&laquo; " + Container.PrevMonth.ToString("MMMM yyyy") %>'
                                    CommandName="PrevMonth" />
                            </td>
                            <td>
                                <h3>
                                    <asp:Label ID="label2" runat="server" Text='<%# Container.CurrentMonth.ToString("MMMM yyyy") %>' /></h3>
                            </td>
                            <td>
                                <asp:LinkButton ID="NextMonth" runat="server" Text='<%# Container.NextMonth.ToString("MMMM yyyy") + " &raquo;" %>'
                                    CommandName="NextMonth" />
                            </td>
                        </tr>
                    </table>
                    <div class="dashedline">
                    </div>
                </HeaderTemplate>
                <DayEventTemplate>
                    <div style="padding: 3px;">
                        <asp:HyperLink ID="HyperLink1" runat="server" Text='<%#Eval("title") %>' NavigateUrl='<%# "Events_view.aspx?Eventid=" + Convert.ToString(Eval("ID"))%>'
                            ToolTip='<%# SharedRoutines.truncate((string)Eval("description")) %>' /></div>
                </DayEventTemplate>
            </ec:EventCalendar>
                </div>
            </div>
    </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="splash" runat="server">
<div id="splash">&nbsp;</div>
</asp:Content>

然而,它会产生错误说:

编译器错误消息:CS0103:当前上下文中不存在名称“SharedRoutines”

为什么会这样?

1 个答案:

答案 0 :(得分:2)

您需要在页面顶部包含包含SharedRoutines类的命名空间,如下所示:

<%@ Import Namespace="Your.Namespace" %>

您也可以在Web.config中全局包含它:

<pages>
    <namespaces>
        <add namespace="Your.Namespace" />
    </namespaces>
</pages>