Jump to content

Calling Sub in Code Behind


swine

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...