Hi counterkin,
Use jQuery for changing the Text.
HTML
<%@ Register TagPrefix="asp" Namespace="Saplin.Controls" Assembly="DropDownCheckBoxes" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body { font-family: Arial; font-size: 10pt; }
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var select = $("[id*=DropDownCheckBoxes1] [id*=caption]");
if (select != null) {
select.html("Select Fruits");
}
var selectAll = $("[id*=checks] span").eq(0).find('label');
if (selectAll != null) {
selectAll.html("Select All Fruits");
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownCheckBoxes ID="DropDownCheckBoxes1" runat="server" Width="180px" UseSelectAllNode="true">
<Style SelectBoxWidth="195" DropDownBoxBoxWidth="160" DropDownBoxBoxHeight="90" />
<Items>
<asp:ListItem Text="Mango" Value="1"></asp:ListItem>
<asp:ListItem Text="Apple" Value="2"></asp:ListItem>
<asp:ListItem Text="Banana" Value="3"></asp:ListItem>
</Items>
</asp:DropDownCheckBoxes>
<asp:ExtendedRequiredFieldValidator ID="ExtendedRequiredFieldValidator1" runat="server"
ControlToValidate="DropDownCheckBoxes1" ErrorMessage="Required" ForeColor="Red">
</asp:ExtendedRequiredFieldValidator>
<br />
<br />
<asp:Button Text="Submit" runat="server" OnClick="Submit" />
</form>
</body>
</html>
Code
C#
protected void Submit(object sender, EventArgs e)
{
string message = string.Empty;
foreach (ListItem item in DropDownCheckBoxes1.Items)
{
if (item.Selected)
{
message += item.Text + " " + item.Value + "\\n";
}
}
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);
}
VB.Net
Protected Sub Submit(sender As Object, e As EventArgs)
Dim message As String = String.Empty
For Each item As ListItem In DropDownCheckBoxes1.Items
If item.Selected Then
message += item.Text + " " + item.Value + "\n"
End If
Next
ClientScript.RegisterClientScriptBlock(Me.GetType(), "alert", "alert('" & message & "');", True)
End Sub
Screenshot