Ajax切换按钮扩展程序不工作

本文关键字:程序 工作 扩展 按钮 Ajax | 更新日期: 2023-09-27 18:12:52

<asp:CheckBox ID="CheckBox1" OnCheckedChanged="CheckBox1_CheckedChanged" runat="server" Text="Toggle Visibility" AutoPostBack="true"/>

和Ajax切换按钮扩展器:

<ajaxToolkit:ToggleButtonExtender ID="Ext1" CheckedImageAlternateText="View" TargetControlID="CheckBox1" runat="server" CheckedImageUrl="~/Images/Others/view.png" UncheckedImageAlternateText="Hide" UncheckedImageUrl="~/Images/Others/hide.png" ImageWidth="32" ImageHeight="24" ></ajaxToolkit:ToggleButtonExtender>

但它不起作用。页面正在加载,但是带有默认的复选框。

感谢您的帮助

Ajax切换按钮扩展程序不工作

您可以这样尝试.....

 <%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckBox myCB = new CheckBox();
        myCB.ID = "myCB";
        myCB.Checked = true;
        myCB.Text = "I like ASP.NET";
        Panel1.Controls.Add(myCB);
        AjaxControlToolkit.ToggleButtonExtender myTBE = new AjaxControlToolkit.ToggleButtonExtender();
        myTBE.TargetControlID = "myCB";
        myTBE.CheckedImageUrl = "ToggleButton_Checked.gif";
        myTBE.UncheckedImageUrl = "ToggleButton_Unchecked.gif";
        myTBE.ImageHeight = 19;
        myTBE.ImageWidth = 19;
        Panel1.Controls.Add(myTBE);                         
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:Panel ID="Panel1" runat="server">            
    </asp:Panel>
    </form>
</body>
</html>
相关文章: