checkboxlist selected item

A

Alex D.

does any body knows how to get the checkbox clicked in a checkboxlist using
the SelectedIndexChanged event? The "EventArgs" dont help too much..
thanks,
Alex.
 
K

Ken Cox - Microsoft MVP

Hi Alex,

That info is contained in ASP.NET's own __EVENTTARGET field. You should be
able to get it from there as shown in the following code.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ 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>
 
A

Alejandro Penate-Diaz

That worked just beatifully. Thanks!

Ken Cox - Microsoft MVP said:
Hi Alex,

That info is contained in ASP.NET's own __EVENTTARGET field. You should be
able to get it from there as shown in the following code.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ 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>

Alex D. said:
does any body knows how to get the checkbox clicked in a checkboxlist
using the SelectedIndexChanged event? The "EventArgs" dont help too
much..
thanks,
Alex.
 
K

Ken Cox - Microsoft MVP

Thanks for letting us know!

Alejandro Penate-Diaz said:
That worked just beatifully. Thanks!

Ken Cox - Microsoft MVP said:
Hi Alex,

That info is contained in ASP.NET's own __EVENTTARGET field. You should
be able to get it from there as shown in the following code.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ 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>

Alex D. said:
does any body knows how to get the checkbox clicked in a checkboxlist
using the SelectedIndexChanged event? The "EventArgs" dont help too
much..
thanks,
Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top