Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2007-03-23
6
1,336 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…

861 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