Link to home
Start Free TrialLog in
Avatar of kinton
kinton

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cognize
Cognize

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

Add MaintainScrollPositionOnPostback="true" in your @Page directive
NazoUK, he's asking to go to another grid on the page, not the same one
Avatar of kinton

ASKER

Correct,  Cognize.  I am trying the anchor method at the moment,
Ah yes, missed that part, sorry.
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.
Avatar of kinton

ASKER

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.