Solved

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

Posted on 2007-03-23
6
1,298 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL best practice question 3 36
Runtime Error 2 27
Syntax Error 2 42
Receiving a string from a WebService Push 21 32
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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 …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A short film showing how OnPage and Connectwise integration works.

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now