日期:2014-05-16  浏览次数:20606 次

Ajax扩展控件

?

18.MutuallyExclusiveCheckBox(复选框相互排斥控件)

该控件可以使复选框实现类似单选框一样的相互排斥的效果

?

<asp:CheckBox ID="CheckBox1" runat="server" Text="黑" />
        <ajax:MutuallyExclusiveCheckBoxExtender ID="CheckBox1_MutuallyExclusiveCheckBoxExtender" 
            runat="server" Enabled="True" Key="颜色" TargetControlID="CheckBox1">
        </ajax:MutuallyExclusiveCheckBoxExtender>
        <asp:CheckBox ID="CheckBox2" runat="server" Text="白" />
        <ajax:MutuallyExclusiveCheckBoxExtender ID="CheckBox2_MutuallyExclusiveCheckBoxExtender" 
            runat="server" Enabled="True" Key="颜色" TargetControlID="CheckBox2">
        </ajax:MutuallyExclusiveCheckBoxExtender>
        <asp:CheckBox ID="CheckBox3" runat="server" Text="大" />
        <ajax:MutuallyExclusiveCheckBoxExtender ID="CheckBox3_MutuallyExclusiveCheckBoxExtender" 
            runat="server" Enabled="True" Key="大小" TargetControlID="CheckBox3">
        </ajax:MutuallyExclusiveCheckBoxExtender>
        <asp:CheckBox ID="CheckBox4" runat="server" Text="小"/>
        <ajax:MutuallyExclusiveCheckBoxExtender ID="CheckBox4_MutuallyExclusiveCheckBoxExtender" 
            runat="server" Enabled="True" Key="大小" TargetControlID="CheckBox4">
        </ajax:MutuallyExclusiveCheckBoxExtender>
?

只有一个值得一提的属性:Key(key属性相同的复选框相互排斥)

?

19.Nobot(拒绝机器人控件)

客户端的验证为了提高用户体验,服务器端的验证才是为了安全性。

http://www.cnblogs.com/abcdwxc/archive/2007/11/06/950816.html

http://www.cnblogs.com/dflying/archive/2007/03/16/676886.html

?

20.Rating(等级评定控件)

http://www.cnblogs.com/jaxu/archive/2009/05/16/1458264.html|推荐

HTML:

<ajax:Rating ID="Rating1" runat="server" StarCssClass="ratingStar" ?

WaitingStarCssClass="savedRatingStar"

FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" CurrentRating="1"?

MaxRating="10" ?OnChanged="Stopawhile">

?</ajax:Rating>

CS:

using AjaxControlToolkit; ? ?//RatingEventArgs

protected void Stopawhile(object sender, RatingEventArgs e)

{

?? //Thread.Sleep(400);

?? ?str = e.Value; ?//e.Value得到的值就是客户选的等级,可在此将其写入数据库

?? Resoponse.Write("客户端看不见此句,但此句执行了");

//由于Rating本身就支持Ajax的无刷新效果,所以上一句Response是执行了,但由于没有回发,所以客户端看不见

}

CSS:

.ratingStar {

?? ?font-size: 0pt;

?? ?width: 13px;

?? ?height: 12px;

?? ?margin: 0px;

?? ?padding: 0px;

?? ?cursor: pointer;

?? ?display: block;

?? ?background-repeat: no-repeat;

}

.filledRatingStar {

?? ?background-image: url(../images/FilledStar.jpg);

}

.emptyRatingStar {

?? ?background-image: url(../images/EmptyStar.jpg);

}

.savedRatingStar {

?? ?background-image: url(../images/SavedStar.jpg);

}

?

?

21.TabContainer(多选项卡容器控件)

如果要在其内的某个TabPanel内添加服务端控件,需给该TabPanel加runat="server"

HTML:

??<ajax:TabContainer ID="TabContainer1" runat="server" Height="100px" Width="400px"?

??OnClientActiveTabChanged="ClientMethod" OnActiveTabChanged="TabPostBack"?

?? AutoPostBack="True">

?? ?<ajax:TabPanel ID="TabPanel1" HeaderText="Tab1" runat="server" ForeColor="Highlight">

?? ?<ContentTemplate>

?? ?<asp:TextBox ID="TextBox1" runat="server">123</asp:TextBox>

?? ?</ContentTemplate>

?? ?