CheckListBox MouseOver

G

Guest

Hi ALL,

Can any one give me a solution to handle mouse over event of each of the
Check Box Control in a CheckListBox Control.

Thanks in advance

Regards
Vidds
 
C

cbDevelopment

The items that you would need to modify in the CheckBoxList are private,
so they can't be manipulated. If this is a absolute must-have, you can
resort to modifying the rendered output of the control to do what you
want.

Add this class:
Public Class ChkboxListWithMouseOver
Inherits CheckBoxList

Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
Dim html As String
Dim sw As New IO.StringWriter
Dim capture As New HtmlTextWriter(sw)

MyBase.Render(capture)

html = sw.GetStringBuilder.ToString
html = html.Replace("type=""checkbox""", _
"type=""checkbox"" onmouseover=""alert('you moused
over.');""")

writer.WriteLine(html)

End Sub
End Class

Create a page with the control:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TestPage.aspx.vb" Inherits="**YOURPROJECT**.TestPage"%>
<%@register tagprefix="cb" assembly="**YOURPROJECT**"
namespace="**YOURPROJECT**" %> <html>
<body>
<form id="Form1" method="post" runat="server">
<cb:ChkboxListWithMouseOver Runat=server ID="chkList" />
</form>
</body>
</html>

(**YOURPROJECT** is the name of your project. You must replace this
value. If you are using namespaces, edit accordingly.)

Hope this helps.

--
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top