AJAX Control Toolkit - ToggleButton(切换按钮)

1.控件效果

Demo

2.ToggleButton Server Properties

TargetControlID - The ID of The CheckBox to modify.

ImageHeight\ImageWidth - The height and width of the image.

CheckedImageUrl - The URL of the image to show when the toggle is in the checked state.

UnchekedImageUrl - the URL of the image to show when the toggle button is in the unchecked state.

DisabledCheckedImageUrl/DisabledUncheckedImageUrl - the URL of the image to show when the toggle button is disabled and in the checked/unchecked state.

CheckedImageOverUrl/UncheckedImageOverUrl - the URL of the image to show when toggle button is in the checked/unchecked state and the mouse is over the button.

CheckedImageAlternateText/UncheckedImageAlternateText - The alt text to show when the toggle button is in the checked/unchecked state.

CheckedImageOverAlternateText/UnchckedImageOverAlternateText - The alt Text to show when the toggle button is in the checked/unchecked state and the mouse is over button.<这两个属性不知道怎么设置>

3.Demo Resources Code

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CheckBox ID="CheckBox1" Checked="true" Text=" I like ASP.NET" runat="server" />
<br />
<asp:CheckBox ID="CheckBox2" Checked="true" Text=' I like "AJAX"' runat="server" />
<asp:CheckBox ID="CheckBox3" Checked="true" Enabled="false" Text=' I like "YM"'
runat
="server" />
<asp:CheckBox ID="CheckBox4" Checked="false" Enabled="false" Text=' I like "LMQ"'
runat
="server" />
<br />
<br />
<asp:Button ID="Button1" Font-Names="Comic Sans MS" runat="server" Text="Submit"
OnClick
="Button1_Click" />
<br />
<br />
<asp:Label ID="Label1" Font-Size="18px" runat="server" Text="[No response provided yet]"></asp:Label>
<ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtender3" runat="server"
TargetControlID
="CheckBox3"
DisabledCheckedImageUrl
="images/disableChecked.gif"
DisabledUncheckedImageUrl
="images/disableUnchecked.gif"
ImageWidth
="19" ImageHeight="19"
UncheckedImageUrl
="images/ToggleButton_Unchecked.gif"
CheckedImageUrl
="images/ToggleButton_Checked.gif" />
<ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtender4"
TargetControlID
="CheckBox4"
DisabledCheckedImageUrl
="images/disableChecked.gif"
DisabledUncheckedImageUrl
="images/disableUncheked.gif"
ImageWidth
="19" ImageHeight="19"
UncheckedImageUrl
="images/ToggleButton_Unchecked.gif"
CheckedImageUrl
="images/ToggleButton_Checked.gif" runat="server">
</ajaxToolkit:ToggleButtonExtender>
<ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtender1" runat="server"
TargetControlID
="CheckBox1"
UncheckedImageUrl
="images/ToggleButton_Unchecked.gif"
CheckedImageUrl
="images/ToggleButton_Checked.gif"
CheckedImageAlternateText
="Check"
UncheckedImageAlternateText
="UnCheck" ImageWidth="19"
ImageHeight
="19">
</ajaxToolkit:ToggleButtonExtender>
<ajaxToolkit:ToggleButtonExtender ID="ToggleButtonExtender2" runat="server"
TargetControlID
="CheckBox2"
ImageWidth
="19" ImageHeight="19"
UncheckedImageUrl
="images/ToggleButton_Unchecked.gif"
CheckedImageUrl
="images/ToggleButton_Checked.gif"
CheckedImageAlternateText
="Check"
UncheckedImageAlternateText
="UnCheck">
</ajaxToolkit:ToggleButtonExtender>
</ContentTemplate>
</asp:UpdatePanel>

  

 1  protected void Button1_Click(object sender, EventArgs e)
2 {
3 string strSelections = "";
4 if (CheckBox1.Checked)
5 {
6 strSelections = "You said you LIKE ASP.NET ";
7 }
8 else
9 {
10 strSelections = "You said you DON'T Like ASP.NET ";
11 }
12 if (CheckBox2.Checked)
13 {
14 strSelections += "and you LIKE MS AJAX ";
15 }
16 else
17 {
18 strSelections += "and you DON'T Like MS AJAX";
19 }
20 Label1.Text = strSelections;
21
22 string strMySelect = "";
23
24 if (CheckBox3.Checked)
25 {
26 strMySelect = "<br />You Love YM";
27 }
28 else
29 {
30 strMySelect = "<br /> You Don't love YM";
31 }
32 if (CheckBox4.Checked)
33 {
34 strMySelect += " and she love your too";
35 }
36 else
37 {
38 strMySelect += " but she don't love you";
39 }
40 Label1.Text += strMySelect ;
41 }

  

你可能感兴趣的:(button)