程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> ajax擴展控件(2)

ajax擴展控件(2)

編輯:.NET實例教程


AlwaysVisibleControl控件,控件用於 將有該控件指定的面板或者空間,在頁面指定的方式顯示出來。

頁面代碼如下:



<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="AlwaysVisibleControlDemo.ASPx.cs" 
Inherits="AlwaysVisibleControlDemo" %>

<%...@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="ASP" %>

<%...@ Register Assembly="AjaxControlToolkit" Namespace="AJaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHtml 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xHtml1-transitional.dtd">

<html XMLns="http://www.w3.org/1999/xHtml" >
<head runat="server">
    <title>無標題頁</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;<ASP:ScriptManager ID="ScriptManager1" runat="server">
        </ASP:ScriptManager>
        <ASP:UpdatePanel ID="update" runat="server">
            <ContentTemplate>
          &n
bsp;     <div >
                    <ASP:Panel ID="displayPanel" runat="server"
                        Width="220px" BackColor="White" ForeColor="DarkBlue"
                        BorderWidth="2" Border BorderColor="DarkBlue" >
                        <div ><p>可移動Panel:</p></div>
                    </ASP:Panel>
                    <cc1:AlwaysVisibleControlExtender ID="avce" runat="server"
                            TargetControlID="displayPanel"
                            VerticalSide="Top" VerticalOffset="10"
                            HorizontalSide="Right" HorizontalOffset="10"
                            ScrollEffectDuration=".1" />
                </div>
                <p>
                選擇需要移動到的Panel位置.  
                </p>
                <p>
                
                Position: <ASP:DropDownList ID="ddlPosition" runat="server" 
                    AutoPostBack="true" OnSelectedIndExchanged="OnChange">
                    <ASP:ListItem Text="默認" Selected="true"  Value="None" />
                    <ASP:ListItem Text="左上" Value="TL" />

<ASP:ListItem Text="上中" Value="TC" />

                    <ASP:ListItem Text="右上"  Value="TR" />
                    <ASP:ListItem Text="左中" Value="ML" />
                    <ASP:ListItem Text="中中" Value="MC" />
                    <ASP:ListItem Text="右中"  Value="MR" />
                    <ASP:ListItem Text="左下" Value="BL" />
                    <ASP:ListItem Text="中下" Value="BC" />
                    <ASP:ListItem Text="右下" Value="BR" />
                </ASP:DropDownList>
                </p>
                
            </ContentTemplate>
         </ASP:UpdatePanel>
        &nbsp;
    </div>
    </form>
</body>
</Html>



程序代碼如下:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using AJaxControlToolkit;

public partial

 class AlwaysVisibleControlDemo : System.Web.UI.Page

...{
    protected void Page_Load(object sender, EventArgs e)
    ...{
        if (!IsPostBack)
            avce.Enabled = false;
    }
    protected void OnChange(object sender, EventArgs e)
    ...{
        if (string.IsNullOrEmpty(ddlPosition.SelectedValue) || ddlPosition.SelectedValue.Length != 2)
        ...{
            avce.Enabled = false;
            return;
        }

        avce.Enabled = true;
        switch (ddlPosition.SelectedValue[0])

 ...{
            case ''T'':
                avce.VerticalSide = VerticalSide.Top;
                break;
            case ''M'':
                avce.VerticalSide = VerticalSide.Middle;
                break;
            case ''B'':
                avce.VerticalSide = VerticalSide.Bottom;
                break;
            default:
                avce.Enabled = false;
                return;
        }

        switch (ddlPosition.SelectedValue[1])
        ...{
            case ''L'':
                avce.HorizontalSide = HorizontalSide.Left;
                break;
            case ''C'':
                avce.HorizontalSide = HorizontalSide.Center;
                break;
            case ''R'':
     &
nbsp;          avce.HorizontalSide = HorizontalSide.Right;
                break;
            default:
                avce.Enabled = false;
                return;
        }
    }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved