国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Rich控件二

2019-11-14 15:47:37
字體:
來源:轉載
供稿:網友

Calendar控件 

使用案例:

Default.aspx中:

 1 <div> 2  3   <h1>Calendar控件</h1> 4  5     <asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="#FFCC66" BorderWidth="1px"  6  7                 DayNameFormat="Shortest" Font-Names="VerDana" Font-Size="8pt" ForeColor="#663399" Height="300px" 8  9                 ShowGridLines="true" width="400px" OnDayRender="Calendar1_DayRender" OnSelectionChanged="Calendar1_SelectionChanged" 10 11       OnVisibleMonthChanged="Calendar1_VisibleMonthChanged">12 13                 <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="true"/>14 15                 <SelectorStyle BackColor="#FFCC66"/>16 17                 <TodayDayStyle BackColor="#FFCC66" ForeColor="White"/>18 19                 <OtherMonthDayStyle BackColor="#CC9966"/>20 21                 <NextPRevStyle Font-Size="9pt" ForeColor="#FFFFCC"/>22 23                 <DayHeaderStyle BackColor="#FFCC66" Font-Bold="true" Height="1px"/>24 25                 <TitleStyle BackColor="#660000" Font-Bold="true" Font-Size="9pt" ForeColor="#FFFFCC"/>26 27             </asp:Calendar>28 29   <br/>30 31   <br/>32 33   <asp:Label ID="Label1" runat="server"/>34 35 </div>

在Default.aspx.cs中:

 1 protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) 2 { 3   //定義假日顯示樣式1 4   Style vacStyle1 = new Style(); 5   vacStyle1.BackColor = System.Drawing.Color.Violet; 6   vacStyle1.BorderColor = System.Drawing.Color.Wheat; 7   vacStyle1.BorderWidth = 4; 8  9   //定義假日顯示樣式110   Style vacStyle2 = new Style();11   vacStyle2.BackColor = System.Drawing.Color.Red;12   vacStyle2.BorderColor = System.Drawing.Color.PaleVioletRed;13   vacStyle2.BorderWidth = 4;14 15   //定義周末顯示樣式16   Style weekStyle = new Style();17   weekStyle.BackColor = System.Drawing.Color.Gold;18   string title1 = "十一長假";//假日提示內容19   string title2 = "中秋節";20 21   if ((e.Day.Date == new DateTime(2015, 9, 27)))22   {23     //應用樣式到假日24     e.Cell.ApplyStyle(vacStyle2);25     //定義假日顯示內容,并為假日提供鏈接26     Label Label1 = new Label();27     Label1.Text = "<br>" + "<a href=" + e.SelectUrl + ">" + title2 + "</a>";28     e.Cell.Controls.Add(Label1);29   }30 31   if ((e.Day.Date >= new DateTime(2015, 10, 1)) && (e.Day.Date <= new DateTime(2015, 10, 7)))32   {33     //應用樣式到假日34     e.Cell.ApplyStyle(vacStyle1);35     //定義假日顯示內容,并為假日提供鏈接36     Label Label1 = new Label();37     Label1.Text = "<br>" + "<a href=" + e.SelectUrl + ">" + title1 + "</a>";38     e.Cell.Controls.Add(Label1);39   }40   else if (e.Day.IsWeekend)41     e.Cell.ApplyStyle(weekStyle);42 43   DateTime mytime = new DateTime(2015, 10, 1);44   if (e.Day.Date == mytime)45     e.Day.IsSelectable = true;46   else47     e.Day.IsSelectable = false;48  }49 50 protected void Calendar1_SelectionChanged(object sender, EventArgs e)51 {52   this.Label1.Text = "今天是:" + this.Calendar1.TodaysDate.ToShortDateString() + "<br>" + "你選擇的日期是:"+ 53     this.Calendar1.SelectedDate.ToShortDateString();54 }55 56 protected void Calendar1_VisibleMonthChanged(object sender, MonthChangedEventArgs e)57 {58   if (e.NewDate.Month > e.PreviousDate.Month)59   {60     this.Label1.Text = "下一個月";61   }62   else63   {64     this.Label1.Text = "上一個月";65   }66 }

AdRotator控件

讀取xml文件中的廣告信息

AdRotator1.ad中:

 1 <Advertisements xmlns="http://schemas.microsoft.com/AspNet/AdRotator-Schedule-File"> 2   <Ad xmlns=""> 3     <ImageUrl>~/Images/Sunset.jpg</ImageUrl> 4     <AlternateText>落日</AlternateText> 5     <Impressions>80</Impressions> 6   </Ad> 7   <Ad xmlns=""> 8     <ImageUrl>~/Images/Water hills.jpg</ImageUrl> 9     <AlternateText>荷塘</AlternateText>10     <Impressions>60</Impressions>11   </Ad>12   <Ad xmlns="">13     <ImageUrl>~/Images/Winter.jpg</ImageUrl>14     <AlternateText>冰山</AlternateText>15     <Impressions>90</Impressions>16   </Ad>17 </Advertisements>

Default.aspx中:

1 <div>2   <asp:AdRotator ID="AdRotator1" runat="server"AdvertisementFile="~/App_Data/AdRotator1.ad" />3 </div>

讀取數據庫文件中的廣告信息

在Web.config中:

1 <connectionStrings>2   <add name="ConnectionString1" connectionString="Data Source=追風的蝸牛;Initial Catalog=Adrotator;Integrated Security=True"/>3 </connectionStrings>

在Dfault.aspx.cs中:

1 <div>2   <asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="SqlDataSource1" />3   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ConnectionStrings:ConnectionString1%>" 4     SelectCommand="SELECT [ID],[ImageUrl],[NavigateUrl],[Impressions],[AlternateText] FROM Advertisements">5   </asp:SqlDataSource>6 </div>

MultiViewView控件

Default.aspx中:

 1 <div> 2   <asp:Label Text="請選擇顯示樣式:" runat="server"></asp:Label> 3   <br/> 4   <asp:RadioBUtton ID="RadioButton1" runat="server" AutoPostBack="true" Text="樣式1" GroupName="Group1"  5     OnCheckedChanged="RadioButton_CheckedChanged" />   6   <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" Text="樣式2" GroupName="Group1"  7     OnCheckedChanged="RadioButton_CheckedChanged" /> 8   <hr/> 9   <asp:MultiView ID="MultiView1" runat="server">10     <asp:View ID="View1" runat="server">11       <asp:Label ID="Label1" Text="樣式一" runat="server"></asp:Label>12     </asp:View>13     <asp:View ID="View2" runat="server">14       <asp:Label ID="Label2" Text="樣式二" runat="server"></asp:Label>15     </asp:View>16   </asp:MultiView>17 </div>

Default.aspx.cs中:

1 protected void RadioButton_CheckedChanged(object sender, EventArgs e)2 {3   if (this.RadioButton1.Checked)4     MultiView1.ActiveViewIndex = 0;5   else if (this.RadioButton2.Checked)6     MultiView1.ActiveViewIndex = 1;7 }

Wizard控件

Default.aspx中:

 1 <div> 2   <asp:Wizard ID="Wizard1" runat="server"> 3     <WizardSteps> 4       <asp:WizardStep Title="step1" runat="server"> 5         <asp:Label runat="server" Text="姓名:"/> 6         <asp:TextBox ID="TextBox1" runat="server"/> 7       </asp:WizardStep> 8       <asp:WizardStep Title="step2" runat="server"> 9         <asp:Label runat="server" Text="性別:"/>10         <asp:TextBox runat="server" ID="TextBox2"/>11       </asp:WizardStep>12       <asp:WizardStep Title="step3" runat="server">13         <asp:Label runat="server" Text="電話:"/>14         <asp:TextBox ID="TextBox3" runat="server" />15       </asp:WizardStep>16     </WizardSteps>17   </asp:Wizard>18 </div>

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 富川| 芮城县| 白银市| 杭锦旗| 福清市| 临江市| 四川省| 正阳县| 酒泉市| 永靖县| 砚山县| 宁安市| 库伦旗| 滦南县| 仁怀市| 隆化县| 安宁市| 桐梓县| 大同市| 杭州市| 新巴尔虎右旗| 湘潭市| 理塘县| 化隆| 新宁县| 江城| 筠连县| 承德市| 曲周县| 盐池县| 喀什市| 都兰县| 会东县| 九龙坡区| 景东| 巴马| 枣庄市| 北京市| 桐城市| 汪清县| 抚顺县|