Dynamic PostBackUrl from JavaScript

I have a ASP.NET page that is updated dynamically via WebServices and JavaScript. There is a LinkButton that needs to go to 1 of 2 pages depending on the state of the page when it is clicked. This is contained in a MasterPage with hidden fields that need to be maintained so It needs to do a PostBack. How do I either change the PostBackUrl of the LinkButton each time a WebService updates the page or determine which page to redirect to when the button is clicked?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Refael AckermannCommented:
I believe the best result is to use JavaScript:
  1. Set the link button to have only OnClientClick="Navigate(); return false;" and no OnClick so there will not be any postback.
  2. Use the following JavaScript function code, and setup your parameters (hidden-field name, value, and pages' URLs)
function Navigate()
  var hiddenField1 = document.getElementById("<%= hiddenField1.ClientID %>");
  if (hiddenField1.value == "Something")
    location.href = "Page1.aspx";
    location.href = "Page2.aspx";

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DerekWatlingAuthor Commented:
This works for redirecting, but I need a Cross Page PostBack as I am using HiddenFields on the MasterPage to track session variables.

After trying various other things I have decided the easiest is to have 2 Image buttons on the page each with a static PostBackUrl and set the display property on the client so that only the relevant button is displayed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.