LinkButton Visited Link on ASP.NET Gridview Issue

J

Jeff

Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET
GridView with paging and sorting.
One of the columns of this Gridview is a template column (LinkButton). The
data being retrieved and showed in this GridView produce more than one page
of data.
A given user clicks on the first row hyper link on the Grid on the first
page, then the first row hyper link color changes to look as "visited".
Then the user navigates to a different page number on the GridView by
clicking on the page number (say 2).
Then on the 2nd page, the color of first row hyperlink on the Grid is
automatically changed to look as visited even though he is navigating to the
page number 2 for the first time.
Users would expect the hyper links on the 2nd (or any other ) page should
look like not visited, when they are navigating for the first time and not
yet clicked on the hyper link.

Any ideas on how to solve this?
Thanks for your help.
 
G

Guest

Jeff,

In your template link add a unique id as part of the hyperlink target - this
will ensure that the browser recognises them as different links.
By default GridView injects a row number into the hyperlink, so that ASP.Net
can tell which link button is generated the click. As your row numbers are
the same on page 1 as on the subsequent pages - you can see that the browser
marks them as been clicked on.

Hope it makes sense
 
M

marss

Hi, I have a ASP.NET 2.0 Web Application. Many of the pages use the ASP.NET
GridView with paging and sorting.
One of the columns of this Gridview is a template column (LinkButton). The
data being retrieved and showed in this GridView produce more than one page
of data.
A given user clicks on the first row hyper link on the Grid on the first
page, then the first row hyper link color changes to look as "visited".


Because LinkButton does not redirect to another url the "visited/
unvisited pages" concept has no sense in this case. Maybe is it better
do not change the color of these linkbuttons at all? It can be done
with CSS.

<style type="text/css">
a.btn, a.btn:link, a.btn:active, a.btn:visited, a.btn:hover
{
color: blue;
}
</style>
....
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="btn"></
asp:LinkButton>

Regards,
Mykola
http://marss.co.ua
 
J

Jeff

Thanks Mikola for your answer.
Well, the thing is that in our case the linkbutton does redirects the user
to another page. What we do is a postback to the same page where we then
setup some needed variables and then we redirect the user to another page ,
say page 2 that uses those variables.

Thanks again for your help.
 
J

Jeff

Thanks Sergey for your responce.

The problem here is that even though theres a way to make unique the gridview's name or the linkbutton's name, the final name of the linkbutton within each row in the gridview is a composition of the gridview's name plus the linkbutton's name plus (and this is the part that I cannot modify) a internal sequence based on the row's number. In other words:

For each row in the gridview that has a linkbutton, there's gonna be a line like the following:

<a id="GridView1_ctl02_Control1" href="javascript:__doPostBack('GridView1$ctl02$Control','')">This is a link</a>

and instead of ctl02 it would be ctl03, ctl04, ctl05 and so on...

The part of the line that is in red is where I don't have control. So It doesn't matter if I customize the gridview's name or the linkbutton's name and append to them an unique value. The ctl02 part is gonna be assigned to the 2nd row always, the ctl03 is gonna be assigned to the 3rd row always and so forth, so, there's where I loose control over it.

If we just could take control over this part that the asp.net gridview generates...the ctl02, ctl03, ctl04....it would be a diferent history... :(

Hope I made myself clear...

Thanks guys...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top