Solved

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

Posted on 2007-03-23
6
1,285 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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.

759 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

22 Experts available now in Live!

Get 1:1 Help Now