<% @ page language="c#" %>
<script language="c#" runat="server">
public void adv(Object src,AdCreatedEventArgs e){
lb1.Text=(String)e.ImageUrl;
lb2.Text=(String)e.NavigateUrl;
lb3.Text=(String)e.AlternateText;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server">
<asp:AdRotator id="ad" OnAdCreated="adv" AdvertisementFile="ad.xml"  runat="server" /><br>
当前文件:<asp:Label id="lb1" runat="server" /><br>
连接地址:<asp:Label id="lb2" runat="server" /><br>
说明文字:<asp:Label id="lb3" runat="server" /><br>
</form>
</body>
</html>
====================================
ad.xml
=====================
<?xml version="1.0" encoding="gb2312" ?>
<Advertisements>
<Ad>
<ImageUrl>1110021951q5.jpg</ImageUrl>
<NavigateUrl>http://www.automa.cn</NavigateUrl>
<AlternateText>天津奥特玛技术开发有限公司</AlternateText>
<Keywork>website</Keyword>
<Impressions>50</Impressions>
</Ad>
<Ad>
<ImageUrl>1110021984q3.jpg</ImageUrl>
<NavigateUrl>http://www.automa.cn</NavigateUrl>
<AlternateText>天津奥特玛技术开发有限公司</AlternateText>
<Keywork>website</Keyword>
<Impressions>50</Impressions>
</Ad>
</Advertisements>
====================================
错误:
=================================
Server Error in '/nns' Application.
--------------------------------------------------------------------------------Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Invalid enum value.Source Error: 
Line 2:  <configuration>
Line 3:   <system.web>
Line 4:   <customErrors mode="off"/>
Line 5:   <compilation debug="true"/></system.web>
Line 6:  </configuration>
 Source File: G:\aspnet\samples\web.config    Line: 4 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42; ASP.NET Version:2.0.40607.42

解决方案 »

  1.   

    把web.config中的编码方式从utf-8改为gb2312
      

  2.   

    <% @ page language="c#" %>
    <script language="c#" runat="server">
    void onselection(Object src,EventArgs e){
    switch(calendar1.SelectedDates.Count){
    case(0):
    lb1.Text="没有选择日期";
    break;
    case(1):
    lb1.Text="选择的日期为:"+calendar1.SelectedDate.ToShortDateString();
    break;
    case(7):
    lb1.Text="选择的周的开始日期为:"+calendar1.SelectedDate.ToShortDateString();
    break;
    default:
    lb1.Text="选择月的开始日期为:"+calendar1.SelectedDate.ToShortDateString();
    break;
    }
    }
    void DayRender(Object src,DayRenderEvenArgs e){
    CalendarDay d=e.Day;
    TableCells c=e.Cell;
    if(d.IsToday){
    c.BackColor=Color.Yellow;
    }
    if(d.IsWeekend){
    c.Controls.Add(new LiteralControl("周末"));
    c.BackColor=Color.Red;
    }
    }
    </script>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <body>
    <form runat="server">
    <asp:Calendar  id="calendar1" runat="server"
    NextPrevFormat="CustomText"
    NextMonthText="下个月"
    PrevMonthText="上个月"
    SelectionMode="DayWeekMonth"
    SelectWeekText="选择整周"
    SelectMonthText="选择整月"
    OnSelectionChanged="onselection"
    OnDayRender="DayRender"
    />
    <asp:Label id="lb1" runat="server" />
    </form>
    </body>
    </html>
    ============================
    错误:
    ================
    Server Error in '/nns' Application.
    --------------------------------------------------------------------------------Configuration Error 
    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Invalid enum value.Source Error: 
    Line 4:   <system.web>
    Line 5:                  <globalization requestEncoding="gb2312" responseEncoding="gb2312" />
    Line 6:   <customErrors mode="on"/>
    Line 7:   <compilation debug="true"/></system.web>
    Line 8:  </location>
     Source File: G:\aspnet\samples\web.config    Line: 6 
    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.40607.42; ASP.NET Version:2.0.40607.42 
    ==================================================
    web.config
    ===========================
    <?xml version="1.0"?>
    <configuration>
    <location>
    <system.web>
                    <globalization requestEncoding="gb2312" responseEncoding="gb2312" />
    <customErrors mode="on"/>
    <compilation debug="true"/></system.web>
    </location>
    </configuration>