效果图片:(注意这里DropDownList可以选择在网页上的位置)

//注意这里引入了Dll的命名空间 还要注意的是设置AlwaysVisibleControlExtender
                          //控件帮定到UpdataPanel里的Panel
                          //取数的时候是这样的  
                          //00 01 02
                          //10 11 12
                          //20 21 22
                          //这个DropDownList1.SelectedValue[0]是取选中的第一个字符是字符用单引''

显示页面的ASPX文件
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title>AJAX之AlwaysVisibleControlExtender</title>
</head>
<body style="text-align: center">
    
<form id="form1" runat="server">
        
<asp:ScriptManager ID="ScriptManager1" runat="server" />
        
<div>
            
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                
<ContentTemplate>
                    
<asp:Panel ID="showPanel" runat="server" Height="152px" Width="256px" BackColor="#C0FFC0" BorderColor="#C0C0FF" BorderWidth="3px" HorizontalAlign="Center">
                        
<br />
                        
<br />
                        欢迎光临欧欧博客
<br />
                        
<br />
                        http:
//chenou.cnblogs.com<br />
                    </asp:Panel>
                    
<cc1:AlwaysVisibleControlExtender ID="avce" runat="server" HorizontalSide="Center" TargetControlID="showPanel" VerticalSide="Middle">
                    
</cc1:AlwaysVisibleControlExtender>
                    
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="104px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                        
<asp:ListItem Value="None">默认</asp:ListItem>
                        
<asp:ListItem Value="00">上左</asp:ListItem>
                        
<asp:ListItem Value="01">上中</asp:ListItem>
                        
<asp:ListItem Value="02">上右</asp:ListItem>
                        
<asp:ListItem Value="10">中左</asp:ListItem>
                        
<asp:ListItem Value="11"></asp:ListItem>
                        
<asp:ListItem Value="12">中右</asp:ListItem>
                        
<asp:ListItem Value="20">下左</asp:ListItem>
                        
<asp:ListItem Value="21">下中</asp:ListItem>
                        
<asp:ListItem Value="22">下右</asp:ListItem>
                    
</asp:DropDownList>
                
</ContentTemplate>
            
</asp:UpdatePanel>
        
</div>
    
</form>
</body>
</html>


主页面的.cs文件

using System;
using System.Data;
using System.Configuration;
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; //注意这里引入了Dll的命名空间 还要注意的是设置AlwaysVisibleControlExtender
                          
//控件帮定到UpdataPanel里的Panel
                          
//取数的时候是这样的   
                          
//00 01 02
                          
//10 11 12
                          
//20 21 22
                          
//这个DropDownList1.SelectedValue[0]是取选中的第一个字符是字符用单引 ''

public partial class _Default : System.Web.UI.Page 
{
    
protected void Page_Load(object sender, EventArgs e)
    
{

    }

    
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    
{
        
switch (DropDownList1.SelectedValue[0])
        

            
case '0':
                avce.VerticalSide 
= VerticalSide.Top;
                
break;
            
case '1':
                avce.VerticalSide 
= VerticalSide.Middle;
                
break;
            
case '2':
                avce.VerticalSide 
= VerticalSide.Bottom;
                
break;
            
default :
                avce.VerticalSide 
= VerticalSide.Middle;
                
return;
        }

        
switch (DropDownList1.SelectedValue[1])
        
{
            
case '0':
                avce.HorizontalSide 
= HorizontalSide.Left;
                
break;
            
case '1':
                avce.HorizontalSide 
= HorizontalSide.Center;
                
break;
            
case '2':
                avce.HorizontalSide 
= HorizontalSide.Right;
                
break;
            
default:
                avce.HorizontalSide 
= HorizontalSide.Center;
                
return;
        }


    }

}
posted on 2007-03-28 21:51  小角色  阅读(243)  评论(0)    收藏  举报