By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,320 Members | 2,109 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,320 IT Pros & Developers. It's quick & easy.

LinkButton Visited Link on ASP.NET Gridview Issue

P: n/a
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.
Sep 6 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

"Jeff" wrote:
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.
Sep 7 '07 #2

P: n/a
On 7 , 00:08, "Jeff" <jeffrey.sanchez.isth...@gmail.comwrote:
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

Sep 7 '07 #3

P: n/a
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.
"marss" <ma******@gmail.comwrote in message
news:11*********************@o80g2000hse.googlegro ups.com...
On 7 , 00:08, "Jeff" <jeffrey.sanchez.isth...@gmail.comwrote:
>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

Sep 7 '07 #4

P: n/a
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$Con trol','')">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...

"Sergey Poberezovskiy" <Se*****************@discussions.microsoft.comwrot e in message news:07**********************************@microsof t.com...
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

"Jeff" wrote:
>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.
Sep 7 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.