Probably as you came across, we can’t able to access to the event args associated with checkbox clicked in a checkboxlist using the SelectedIndexChanged event.
But you can. That info is contained in ASP.NET's own __EVENTTARGET field.
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load _(ByVal sender As Object, _ ByVal e As System.EventArgs)
If IsPostBack Then
Response.Write("Postback by: " & _
Request.Form("__EVENTTARGET") & "<br />")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Who posted back?</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:checkboxlist id="CheckBoxList1" runat="server" autopostback="True">
<asp:listitem>Red</asp:listitem>
<asp:listitem>Green</asp:listitem>
<asp:listitem>Blue</asp:listitem>
</asp:checkboxlist></div>
</form>
</body>
</html>
You should be able to get it from there as shown in the following code:
But you can. That info is contained in ASP.NET's own __EVENTTARGET field.
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load _(ByVal sender As Object, _ ByVal e As System.EventArgs)
If IsPostBack Then
Response.Write("Postback by: " & _
Request.Form("__EVENTTARGET") & "<br />")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Who posted back?</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:checkboxlist id="CheckBoxList1" runat="server" autopostback="True">
<asp:listitem>Red</asp:listitem>
<asp:listitem>Green</asp:listitem>
<asp:listitem>Blue</asp:listitem>
</asp:checkboxlist></div>
</form>
</body>
</html>
You should be able to get it from there as shown in the following code: