• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 783
  • Last Modified:

ASP.Net Button field anchor

Hi,

I have the attached code in a data grid.  The button field populates another grid lower down on the same page.  When the user clicks the button the grid populates fine.  How can I put an anchor in so the page alos jumps to that data grid?

thanks
<asp:ButtonField DataTextField="Name" HeaderText="NAME" ButtonType="Link" 
												HeaderStyle-CssClass="GridViewHeaderColOne" ShowHeader="True" 
												SortExpression="Name"  >
											<HeaderStyle CssClass="GridViewHeaderColOne"  />
											</asp:ButtonField>

Open in new window

0
kinton
Asked:
kinton
  • 3
  • 2
  • 2
  • +1
1 Solution
 
GiftsonDJohnCommented:
Hi,

You have to use
              <a name="Grid2"></a>
just before the Grid2 and call javascript function on the page load

location.hash="Grid2";
0
 
CognizeCommented:
A few options:

1. You can use the OnClientClick property of the control, and then use javascript to navigate to a particular point in the page.

Javascript: window.scrollTo(posX, posY);

2. I have sometimes had varying results with the OnClientClick in different browsers, so another option is to add <span> tags around the ASP control, and add JavaScript in the span elements onclick event.

You might also be able to do something clever with html anchors. Maybe try surrounding the control with an <a> tag and set properties as below:

1. an anchor in the spot that you are going to jump from
this anchor will have the syntax:
<a href="#anyword">Jump to anyword</a>

2. a named anchor in the spot that you are going to jump to
this anchor will have the syntax:
<a name="anyword">TEXT</a>



window.scrollTo(posX, posY);

Open in new window

0
 
NazoUKCommented:
Add MaintainScrollPositionOnPostback="true" in your @Page directive
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
CognizeCommented:
NazoUK, he's asking to go to another grid on the page, not the same one
0
 
kintonAuthor Commented:
Correct,  Cognize.  I am trying the anchor method at the moment,
0
 
NazoUKCommented:
Ah yes, missed that part, sorry.
0
 
CognizeCommented:
You know, you might actually get on better with GiftsonDJohn, since the anchor method won't work if you are trying to download at the same time.
0
 
kintonAuthor Commented:
That worked!  thanks.

I've marked the solution as partially complete as anyone else looking at this will need to write their own Java script in.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now