Solved

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

Posted on 2007-03-23
6
1,357 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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