Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6688215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:22:43+00:00 2026-05-26T05:22:43+00:00

I am trying to redirect the user to a different page upon clicking on

  • 0

I am trying to redirect the user to a different page upon clicking on a button and stop any asp related events if it meets the validation in the if() statement in javascript, the reason why i am doing it like this is because on a specific page.. it is not grabinhg the On_Click event for some reason. While debugging it.. before it goes into the On_Click event in the .cs file it call multiple classes and functions .. by the time it is done.. it is redirecting somewhere else and never goes through the On_Click event.. now these are a dozen of classes it is going through so I decided to use javascript to do it right after the button is clicked without letting it evaluate in .cs BUT i still want to allow that for other pages because it is working there.. this page seems to be special..

When i click on the image button it is supposed to check the function first and then if its true redirect and stop any other processing on Page_Load or anywhere but its not working see my code here in my user control

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FindPage.ascx.cs"
    Inherits="Data_Manager_FindPage" %>
<script type="text/javascript">
    function ForwardSearch() {
        if (window.location.href.indexOf('FindPage.aspx') > -1) {
            var value = document.getElementById('<%= txtFind.ClientID %>').value;
            window.location.href = '~/ResultSet.aspx?findvalue=' + encodeURIComponent(value);
        }
    }

</script> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:22:44+00:00Added an answer on May 26, 2026 at 5:22 am

    One issue is that your ForwardSearch() JavaScript function does not explicitly return true / false.

    When you add “OnClientClick=’return ForwardSearch();'” it will use the result of the function to determine if it should continue executing. Since your ForwardSearch() doesn’t return anything it defaults to return true and therefore it will continue executing and eventually call your server-side btnFind_Click.

    try:

    <script type="text/javascript">
    function ForwardSearch() {
        if (window.location.href.indexOf('FindPage.aspx') > -1) {
            var value = document.getElementById('<%= txtFind.ClientID %>').value;
            window.location.href = '~/ResultSet.aspx?findvalue=' + encodeURIComponent(value);
            return false;
        }
        return true;
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to redirect a user to a different asp page with some
I am trying to redirect the user to a different page after 1 second
I have been trying to redirect the user to the review page. I tried
I'm trying to perform a redirect to a different page in Javascript AND also
Ok, I have an default.aspx page that I'm trying to have redirect the user
I'm trying to redirect this page Page to a Jquery mobile website that I'm
I'm trying to redirect to a .php page if the $validForm variable is TRUE.
i am trying to redirect users without javascript enabled to our help page (help.php),
So I'd like to redirect mobile users to a different page. But instead of
I'm trying to create an account register page with CakePHP 2.0 where user needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.