swine Posted September 28, 2012 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 28, 2012 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. Link to comment Share on other sites More sharing options...
swine Posted October 1, 2012 Author 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now