Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Please help me to define a sub for td of Datalist in VB.Net

Here is my Design Code:
HTML
<asp:DataList ID="sideMenu" runat="server">
<itemtemplate>
<table border="0" cellpadding="0" cellspacing="0" width="170px">
<tr>
<td id="td_Menu"  runat="server" style="background-image:url(Images/BG1.bmp)"  onclick="td_Menu_Click">
<%#DataBinder.Eval(Container.DataItem, "name")%>

<table><tbody><tr>


And a Sub id defined as
VB.NET
Protected Sub td_Menu_Click(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub


But the code has no effect

Thank you
Posted
Updated 6-Jun-11 21:32pm
v2

The snippet of code provided has several errors.
(As far as I can tell)

You are opening the Table, but not closing.
Ditto the TR and the TD.

Then there is a strange line at the bottom...
HTML
<table><tbody><tr>

If they are meant to be the closers, then they are out of order and what is a <tbody> doing there?
 
Share this answer
 
v4
The td don't have server side onclick event. The onclick event which is in the td attributes is client side script(Javascript).

You can do your code for td using Javascript.

Check this[^] to learn Javascript.
 
Share this answer
 
As Toniyo mentioned "onclick" of a TD is a client side event, so either you try to put your logic in client side code (java-script) or if you still need to put the logic at server side, consider using some other control OR you do a postback in your java-script function (the one which is handling "onclick" of TD).
See this link for postback using java-script or better you Google for the same, you might find better answers.
http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900