Solved

asp:table td element onclick event - can it call a vb.net subroutine?

Posted on 2007-03-23
6
1,319 Views
Last Modified: 2011-04-14
I have an asp.net page with an asp table. I would like the items in the table to have onclick events which call vb.net subroutines.

Here is my table:
NB: The onlick events are currently calling a javascript which redirects the page, but I would rather call a vb.net subroutine.

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
        <HeaderTemplate>
        <table style="LEFT: 278px; WIDTH: 880px; POSITION: absolute; TOP: 195px">
        <tr>
        <th class="intraContent"><b>IT Service</b></th>
        <th class="intraContent"><b>Collections</b></th>
        <th class="intraContent"><b>Smart Collections</b></th>
        <th class="intraContent"><b>Static Collections</b></th>
        <th class="intraContent"><b>Published Collections</b></th>
        <th class="intraContent"><b>Released Collections</b></th>
        <th class="intraContent"><b>Query count</b></th>
        </tr>

        </HeaderTemplate>
        <ItemTemplate>
        <tr>
        <td class="intraContent"><a href="Collections.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#DataBinder.Eval(Container.DataItem, "Service_ITEM")%></a></td>
        <td class="intraContent" align="center" onclick="Table_OnClick('<%#databinder.eval(container.dataitem,"Service_id") %>')" style="border-bottom: 2px solid #003355"><%#DataBinder.Eval(Container.DataItem, "Collection_Count")%></td>
        <td class="intraContent" align="center"><a href="Collections.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#DataBinder.Eval(Container.DataItem, "smart_count")%></a></td>
        <td class="intraContent" align="center"><a href="Collections.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#DataBinder.Eval(Container.DataItem, "static_count")%></a></td>
        <td class="intraContent" align="center"><a href="Collections.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#DataBinder.Eval(Container.DataItem, "published_count")%></a></td>
        <td class="intraContent" align="center"><a href="Collections.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#DataBinder.Eval(Container.DataItem, "released_count")%></a></td>
        <td class="intraContent" align="center"><a href="Queries.aspx?service_id=<%#DataBinder.Eval(Container.DataItem,"Service_ID") %>"><%#databinder.eval(container.dataitem,"Query_Count") %></a></td>
        </ItemTemplate>
        <FooterTemplate>
        <tr>
        <!--<tr><td colspan="3"><hr /></td></tr>
        <tr><td class="intraContent">Total:</td><td></td><td></td></tr>
        <tr><td></td><td><%#Databinder.eval(Container.DataItem,"Collection_Count") %></td><td class="intraContent"><%#Databinder.eval(Container.DataItem,"Query_Count") %></td></tr>
        -->
        </table>
        </FooterTemplate>
        </asp:Repeater>

If it is not possible to call a vb.net sub from the onclick event of a td element, then can you suggest any way I can do this?

The reason is because I want to use set and get routines when the user clicks the item in the asp:table.

Thanks,
rss2
0
Comment
Question by:rss2
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18780009
Not sure what you want to make clickable. In the above example you only have one cell  (td) with an onclick .   All the other cells contain <a> refs .. which will respond to a click.
Instead of using the  hyperlink tag you could also use asp:Linkbutton. This has an onclick event which you can respond to in code behind.
0
 

Author Comment

by:rss2
ID: 18780191
The cell with the onclick event is what I'm asking about. I would like to launch into a VB.NET routine instead of javascript. Is that possible?

asp:Linkbutton is a button. I don't want to use a button.

Thanks,
rss2
0
 
LVL 13

Expert Comment

by:KarinLoos
ID: 18780217
asp:Linkbutton is not a button it renders like a hyperlink.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:rss2
ID: 18781311
I tried it, but can't seem to make it work.

Using one of the td elements in my code, can you give me an example of using the asp:Linkbutton showing the onclick event going to a vb.net subroutine and showing the pointer turn into a hand?

Thanks!
0
 
LVL 13

Accepted Solution

by:
KarinLoos earned 500 total points
ID: 18786056
Thats proberly because its within a Repeater. You need to respond to the OnItemCommand of the repeater.
see for the code behind : http://msdn2.microsoft.com/en-us/library/df6hth3s.aspx


and in your html  something like:

 <td class="intraContent" align="center">
       <asp:LinkButton id="linkBUtton1" runat="server" command="service1" ><%#DataBinder.Eval(Container.DataItem, "published_count")%></asp:LinkButton>
</td>


0
 

Author Comment

by:rss2
ID: 18791658
Perfect. thank you!!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Angular JS Route 3 70
Delete HTML table rows 12 28
How to close an asp.net web form using C# ? 4 30
Following an example - Why do I need to click Save button twice? 3 25
Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question