div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Width="161" Height="127"
BorderColor="#C2C2C2" BorderStyle="Dashed" BorderWidth="1px">
<br />
<br />
學習AJAX<br/>
就去playaspx.com</asp:Panel>
<cc1:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1"
runat="server" TargetControlID="Panel1" VerticalSide="Middle">
</cc1:AlwaysVisibleControlExtender>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
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>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DropDownList1.SelectedValue[0].ToString())
{
case "0":
AlwaysVisibleControlExtender1.HorizontalSide = HorizontalSide.Left;
break;
case "1":
AlwaysVisibleControlExtender1.HorizontalSide = HorizontalSide.Center;
break;
case "2":
AlwaysVisibleControlExtender1.HorizontalSide = HorizontalSide.Right;
break;
default:
AlwaysVisibleControlExtender1.HorizontalSide = HorizontalSide.Center;
break;
}
switch (DropDownList1.SelectedValue[1].ToString())
{
case "0":
AlwaysVisibleControlExtender1.VerticalSide = VerticalSide.Top;
break;
case "1":
AlwaysVisibleControlExtender1.VerticalSide = VerticalSide.Middle;
break;
case "2":
AlwaysVisibleControlExtender1.VerticalSide = VerticalSide.Bottom;
break;
default:
AlwaysVisibleControlExtender1.VerticalSide = VerticalSide.Middle;
break;
}
}
常用屬性:
1、TargetControlID: 需要保持’懸浮’狀態的控制項ID.
2、HorizontalSide: 被控制控制項的水平位置,可以為Left, Center,Right,預設值是Left.
3、HorizontalOffset: 結合上面的horizontalSide來使用,如果horizontalSide為Left,那麼把HorizontalOffset設定為10px,表示距離瀏覽器左邊10px。
4、VerticalSide: 被控制控制項的垂直位置,可以為Top,Middle,Bottom。 預設值是Top.
5、VertivcalOffset: 和上面的VerticalSide結合控制控制項距離VerticalSide多少像素。如果VerticalSide設定為Top, VerticalOffset設定為20px,那麼表示控制項距離Top的距離是20px.
6、ScrollEffectDuration: 滾動效果周期設定,我不大清楚有什麼用處。
CS代碼,引入命名空間 using AjaxControlToolkit;