swine 0 Posted September 28, 2012 Report Share Posted September 28, 2012 Hi there, I'm new on ASP.NET and have the following problem: I get some data from a MS SQL-Server using a stored procedure. To display the data I'm using <ul>, <li> in a Repeater, because I have to do some optical customization. Now I want to call a sub from the Code Behind file, by clicking on a List Item. Right now the ClickEvent should just cause a Console output, that the Item was clicked.But I'm getting an error, saying the sub is undefined. Here is the code: <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <li runat="server" onclick="selectItem" data-icon="false"><a href="index.aspx"><%#Eval("Employee")%></a></li> </ItemTemplate> </asp:Repeater> Public Sub selectItem(ByVal sender As Object, ByVal e As System.EventArgs) Console.WriteLine("Clicked") End Sub Thanks for your help Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 28, 2012 Report Share Posted September 28, 2012 It sounds like it's looking for a client-side Javascript function. You may need to use an ASP.NET component like a Hyperlink and specify your events on that instead of on the li tag. Quote Link to post Share on other sites
swine 0 Posted October 1, 2012 Author Report Share Posted October 1, 2012 Thanks for your answer. I've tried an ASP.NET LinkButton but it works not exactly how I need it. The selected Item doesn't remain selected, means doesn't switch color. <li runat="server" data-icon="false"><asp:LinkButton NavigateURL="~/index.aspx" OnClick="selectItem" runat="server" Text=<%#Eval("Employee")%>></asp:LinkButton></li> Maybe some further details will help:The Application has a splitview with employee names on the left, projects on the right. By clicking on a name the non-related projects should grey out. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.