日期:2014-05-18 浏览次数:20437 次
<asp:Repeater ID="rpt" runat="server"> <ItemTemplate> <asp:Button ID="btn" runat="server" Text="按钮" OnCommand="btn_Command"/> </ItemTemplate> </asp:Repeater> 后台cs文件 public void btn_Command(object sender,CommandEventArgs e) { Button btn = sender as Button; btn.Text = "选中"; }
------解决方案--------------------
protected void Repeater1_ItemCommand(object sender, RepeaterItemEventArgs e) { if(e.commandName=="button1") { button bt= e.Item.FindControl("button1") as Button; if(bt.text=="选中") { bt.text="未选中"; } else { bt.text="选中"; } }
------解决方案--------------------
<asp:Button ID="btn" runat="server" Text="点我" onclick="if(this.value=='选中')this.value='未选中';else{this.value='选中';}"/>