客户端动态设置DropShadow控件时,$find()与BehaviorID属性的用途

来源:互联网 发布:阿里云iaas平台特点 编辑:程序博客网 时间:2024/05/22 02:18

     

     

       客户端使用DropShadow控件时,  在程序运行的过程中,无法在客户端使用getDocumentById方法,获取控件DropShadow,必须使用AJAX类库的方法“$find”,否则无法获取客户端的阴影控件。要使用方法“$find”,必须设置控件的BehaviorID属性,然后在客户端的访问中,使用“$find('DropShadowBehavior1')”来获取客户端的AJAX控件,代码如下:

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropShadow_Client.aspx.cs" Inherits="DropShadow_Client"%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<!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>客户端动态设置DropShadow控件</title>
<script language="javascript" type="text/javascript">
<!--
function Button1_onclick() {
var drop=$find("DropShadowBehavior1");
    drop.set_Width(
8); //阴影宽度
    drop.set_Rounded(true);    //显示锐化效果
     drop.set_Radius(8); //锐化幅度       
    drop.set_Opacity(0.7);        // 阴影透明度
}

// -->
</script>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:ScriptManager ID="ScriptManager1" runat="server">
        
</asp:ScriptManager>
    
    
</div>
        
<asp:Panel ID="Panel1" runat="server" BackColor="#E0E0E0" Height="101px" Width="288px"></asp:Panel>
        
<input id="Button1" style="width: 116px" type="button" value="应用配置" language="javascript" onclick="return Button1_onclick()" />
        
<cc1:DropShadowExtender ID="DropShadowExtender1" runat="server"  TargetControlID="Panel1" BehaviorID="DropShadowBehavior1">
  
</cc1:DropShadowExtender>
    
</form>
</body>
</html>