Can you jump to an anchor on postback?

D

darrel

I have an anchor on my page:

<a name="monkey"></a>

I can easily go to this via a redirect, but is there a way to jump to this
on postback?

-Darrel
 
K

Kevin Spencer

Sure. Just add a JavaScript to the page that does the "redirect" -

<script type="text/javascript"><!--
document.location = "thispage.aspx#bookmark";
// --></script>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
O

Ollie Riches

check out using SmartNavigation for returning to the correct place on a page
after a post back

HTH

Ollie Riches
 
D

darrel

check out using SmartNavigation for returning to the correct place on a page
after a post back

Ha! The first result from google is:

"Smart navigation is more of a pain than good."

;o)

I'll look into it, though I'm thinking Kevin's answer might be the solution.
Not a big fan of javascript for this, but since this is on an intranet, it's
not as big of a deal.

-Darrel
 
D

darrel

Sure. Just add a JavaScript to the page that does the "redirect" -
<script type="text/javascript"><!--
document.location = "thispage.aspx#bookmark";
// --></script>

Hmm...does that reload the page or merely jump to the anchor? Would this
work as well:

document.location = "#bookmark";?

-Darrel
 
O

Ollie Riches

SmartNavigation is not a pain at all as long as you remember some very
important folders, make sure that the folders with the prefix '_vti_' are
included in the root directory of the installed asp.net application
otherwise you will see funny behaviour with SmartNavigation, by default they
are installed in \Inetpub\wwwroot automatically so you don't have to worry
about it if your asp.net application resides under this directory.

Also it only works in IE I believe, it does work in Firefox (Mozilla).

HTH

Ollie Riches
 
K

Kevin Spencer

Sure. Six of one of half of one of half of a dozen of the other.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
K

Kevin Spencer

Not a big fan of javascript for this, but since this is on an intranet,

If you're not a big fan of JavaScript, you might as well forget about
ASP.Net, which relies heavily upon JavaScript for much of its functionality
(ViewState, PostBacks, etc)!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
D

darrel

If you're not a big fan of JavaScript, you might as well forget about
ASP.Net, which relies heavily upon JavaScript for much of its functionality
(ViewState, PostBacks, etc)!

It's ridiculous, IMHO. I end up having to simply write a lot of workarounds
for it.

A server side language should not be dependant on client-side scripting, but
MS, as usual, took the easy way out on a lot of the built-in control
behaviors.

They're actually great to whip up quick interfaces on intranets where you
can control the client-side environment to an extent, but useless on the
greater web if accessibility is a concern.

IMHO, of course.

-Darrel
 
M

Matt Berther

Hello darrel,
A server side language should not be dependant on client-side
scripting, but MS, as usual, took the easy way out on a lot of the
built-in control behaviors.

Please do tell how you except a web application not be dependent on client
side scripting. Also, Im interested to hear in how Microsoft "as usual, took
the easy way out".

This is not a fault of Microsoft, but rather the very nature of HTML.
 
D

darrel

Please do tell how you except a web application not be dependent on client
side scripting.

We've been doing it that way for years.
Also, Im interested to hear in how Microsoft "as usual, took
the easy way out"
This is not a fault of Microsoft, but rather the very nature of HTML.

Many of the built in controls require javascript. They could have built the
workarounds themselves...just like I am doing. Is it as elegant? No. But
it's accessible.

As for being lazy...look at client-side form validation and the Ollie's
comment on smart navigation both being dependant on IE. That's laziness.
Take the fact that a datalist using columns and an odd-number dataset can't
generate a compliant table without workarounds. That's laziness. Take the
fact that datagrids and other table-based controls don't give you default
options for table headers and such. Laziness. The fact that VS.net still
messes with my HTML...a known bug by MS that they just don't want to fix.
Laziness.

And MS isn't alone in this...seems to be defacto for software development
these days. ;o)

-Darrel
 
D

darrel

This is not a fault of Microsoft, but rather the very nature of HTML.

FYI, HTML is what it is. The web protocols are what they are. It's a
stateless environment. MS chose to work around this with viewstates and
postbacks and depending on client-side scripting. There simply is a tradeoff
here.

I think it's great for controlled environment application development. I
think the tradoffs start to show when developing public-facing web sites
where accessibility is a priority.

-Darrel
 
K

Kevin Spencer

One man's laziness is another man's productivity.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
M

Matt Berther

Hello darrel,
Many of the built in controls require javascript. They could have
built the workarounds themselves...just like I am doing. Is it as
elegant? No. But it's accessible.

Would you mind describing the workarounds you're talking about?
As for being lazy...look at client-side form validation and the
Ollie's comment on smart navigation both being dependant on IE. That's
laziness. Take the fact that a datalist using columns and an
odd-number dataset can't generate a compliant table without
workarounds. That's laziness. Take the fact that datagrids and other
table-based controls don't give you default options for table headers

I'll give you those. The controls arent perfect, but your statement was pretty
broad.
and such. Laziness. The fact that VS.net still messes with my HTML...a
known bug by MS that they just don't want to fix. Laziness.

This has been resolved in VS.NET 2005.
And MS isn't alone in this...seems to be defacto for software
development these days. ;o)

Without question, you're right there. There has been a definite propensity
by software developers to just hack and bang stuff together and hope that
it works. No regard to proper OO design. If it works, its right. And thats
too bad.
 
D

darrel

Many of the built in controls require javascript. They could have
Would you mind describing the workarounds you're talking about?

Well, the workaround, for me at least, is to depend on lots of querystrings
with redirect and/or setting viewstate properties in the codebehind. I just
can't accept postbacks triggered via javascript on the public site I'm
working on.

-Darrel
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top