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 7921965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:47:13+00:00 2026-06-03T16:47:13+00:00

I have a button like <asp:Button ID=Button1 runat=server Text=Submit onclick=RedirectToLocker OnClientClick=return false; UseSubmitBehavior=false />

  • 0

I have a button like

<asp:Button ID="Button1" runat="server" Text="Submit"  onclick="RedirectToLocker"  
                 OnClientClick="return false;" UseSubmitBehavior="false" />

and a method in the codebehind like

  public void RedirectToLocker(object sender, EventArgs e)
        {
            Response.Redirect(ConfigurationManager.AppSettings["LockerLoginURL"]);

        }

But when I click the button it doesn’t hit the code in the method. If I remove OnClientClick = “return false;” then the button submits the form and goes to the wrong page. What am I doing wrong?

EDIT: I am using the OnClientClick=”return false;” code because without it the button for some reason acts as a submit for the form it is nested in and immediately redirects to the form action url instead of hitting my code.

  • 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-06-03T16:47:16+00:00Added an answer on June 3, 2026 at 4:47 pm

    When a clientside event handler returns false, the postback is omitted.

    OnClientClick="return false;" // <-- no postback
    

    So you either need to remove it or tell us why you actually want to return false from the js-onclick event. If the Response.Redirect goes to the wrong page, you might want to change that.

    Edit: So you’re redirecting to another page by setting the form’s Action to another url. Then you could set the Button’s PostBackUrl to the same url as the current page. Then it would hit the codebehind.

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

Sidebar

Related Questions

I have this ASP.net component: <asp:Button ID=Button4 runat=server Text=Submit Entry CssClass=eventSubmitButton OnClick=SubmitData/> and I'd
i have asp button like this: <asp:Button ID=ImportToDB runat=server OnClick=ImportToDB_Click /> And i need
I have a standard button in my default.aspx page. <asp:Button ID=Search_Button runat=server Text=Search onclick=Search_Button_Click
I have an ASPX file with this button: <asp:button id=cmdPartnerInfo runat=server Font-Bold=True Text=Partner Info
I have one text box and button in asp.net like <tr> <td style=width: 100px>
I have a asp button that while processing i would like the text on
I have a button like this: <Button android:id=@+id/logout_button android:layout_width=fill_parent android:layout_height=wrap_content android:text=Log out /> and
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I have a button on an html page declared like so: <button type=submit name=action
I have a button that basically looks like this: <Button android:id=@+id/admin_new_questions android:layout_width=fill_parent android:layout_height=wrap_content android:text=See

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.