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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:38:45+00:00 2026-06-02T20:38:45+00:00

I have got two buttons, which both submit a form in asp.net. I need

  • 0

I have got two buttons, which both submit a form in asp.net.

I need to know in the function below..What button was clicked..The login or register button. And by that information, I want to trigger the one of the functions in the load event.

    protected void Page_Load(object sender, EventArgs e)
{
    AddCountries();
    AddAge();

      if (IsPostBack)
      {
          string pwd = LoginPassword.Text;
          string saltAsBase64 = "z3llWdYSA2DY3M4uNSpOQw==";
          string hash = HashPass.GenerateHash(pwd, saltAsBase64);

          if (Page.IsValid)
          {
              LoginUser(hash);
         /// Depending on what the user pressed..I need to trigger the function 
        // above or below
              RegisterUser(hash);
          }



      }
}

What if I have this in the button event:

FormsAuthentication.RedirectFromLoginPage(currentUser.UserName, false);

will the redirection happen immediately after the button event? or will it trigger the page load event again, ignoring that redirection?

  • 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-02T20:38:47+00:00Added an answer on June 2, 2026 at 8:38 pm

    If the buttons are server side controls <asp:button/> then you can handle the event of the (specific) button:

    protected void Button1_Click(object sender, EventArgs e) {....}
    

    vs.

    protected void Button2_Click(object sender, EventArgs e) {......}
    

    Which are raised after Page_Load see: ASP.Net Page Life Cycle

    If you are using standard HTML <input type=submit /> and posting back to the same page, then you can inspect the Request.Form collection (which you can also do with server side controls).

    UPDATE:

    • Page_Load is always raised on postback
    • client-side validation will prevent a postback
    • if you are using server validation controls, check Page.IsValid in the handler before executing something
    • Depending on your needs, you can also inspect controls/values in Page_Load (checking for Page.IsPostBack – the point is you have options…

    So if you (instead) wanted to inspect on Page_Load:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            if ((UserEmail.Text == "jchen@contoso.com") &&
             (UserPass.Text == "37Yj*99Ps"))
              {
                FormsAuthentication.RedirectFromLoginPage
                   (UserEmail.Text, Persist.Checked);
              }
            else
              {
                ......
              }
        }
    }
    

    above code taken, and slightly modified, from MSDN

    UPDATE2:

    If you are using server validation controls, don’t use Page_Load. Use the button handler and check for Page.IsValid.

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

Sidebar

Related Questions

I've got a form where I have two radio buttons and two interchangeable controls
I've got two radio buttons in a .net page which are being transformed to
I need to have a single <li> element which has two buttons inside of
llo, I have a form that has two submit buttons: one accept and one
I've got two Silverlight Controls in my project, both have properties TeamId. I would
I am wring a button control like below. i have got a method that
So Basically I have a <div> which contains two buttons. I want to position
I've got a standard HTML form, which is split into two sections using fieldset
I've got a rectangle div in which I want to center two buttons horizontally.
I have created TWO screens which i will paste the code below. `FirstScreen:` i

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.