How to redirect a page with an anchor tag?

hi,
i have a problem and i hope you can help me with it…

In the view.aspx page, i have a datagrid with fill rows of data. when they click on the edit link, they will be redirected to the edit.aspx page. after editing and when they clicks on the submit button, it will save the changes and redirect back to the view.aspx…

i would like to make an anchor link on the view.aspx so that when they get redirected back to the view.aspx, i want them to view the record they have just edited… currently, it’s always display on the top of the page. (i want to reduce vertical scrolling…)

what i have now is i have an add another column for my datagrid for my anchor links… my anchor like is bound to my primary key…

<a name = ‘<%# Container.DataItem(“primarykey”)%>’></a>

in my edit.aspx.vb, when i click on the submit button, i have this…
Response.Redirect(“~/DocumentList/ViewDocumentList.aspx#” & primarykey & “?wsid=” & hidengwc.Text)

but it doesn’t seem to be working… how should i do it? i believe it gotta do with my querystring… they don’t seems to be working if i place them together… (querystring and anchor)

cynthia

The querystring is supposed to come BEFORE the anchor. This isn’t correct:


viewdocument.aspx#a442?wsid=whatever

It’s not correct because the browser assumes you want to jump to the anchor with the name “a442?wsid=whatever”, which doesn’t exist.

This is the correct format:


viewdocument.aspx?wsid=whatever#a442

Hope this helps :slight_smile:

Hmm… Never knew that. It’s good to know.

i tried using this code

viewdocument.aspx?wsid=whatever#a442

but it doesn’t recognise ‘#a442’ as an anchor tag…
it recognise ‘whatever#a442’ as a whole querystring…

any ideas?

That’s weird. This works for me:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>Untitled</title>
</head>

<body>
<h1>Anchor test</h1>
<br/>
<br/>
<br/><br /><br/><br />
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<a name="a442"></a>
<div id="qs">
<script type="text/javascript">
<!--
document.write(location.search);
-->
</script>
</div>

</body>
</html>

If I use the URL


http://localhost/misc/test.html?myvar=whoa#a442

I go to the right place and the querystring is printed out without the hash (#a442).

i’ve got it working… thanx… it’s my own mistake…