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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:31:38+00:00 2026-05-27T16:31:38+00:00

I have two image buttons with Click events assigned to them. There is code

  • 0

I have two image buttons with Click events assigned to them. There is code in each event. When they are clicked it runs the page load function before it runs the code in the click events. How can i get it to run the code in the click events first?

Happy Holidays!

Image buttons.

  protected void Page_Load(object sender, EventArgs e)
    {
        //YesID = "1";
        if (!IsPostBack)
        {

            Session["FirstyesID"] = 0;
            Session["FirstnoID"] = 0;
            Session["SecondnoId"] = 0;
            Session["SecondyesId"] = 0;
            Session["yesID"] = 0;
            Session["noId"] = 0;
        }
        else
        {
            //Run this code
        }
 }
         protected void FirstPicLink_Click(object sender, ImageClickEventArgs e)
    {
        Session["yesID"] = Session["FirstyesID"];
        Session["noId"] = Session["FirstnoID"];
        //FirstPicLink.PostBackUrl = "default.aspx";
        //FirstPicLink.PostBackUrl = "GadgetFS.aspx?yesId=" + firstYesPicId + "&noId=" + firstNoPicId;

    }

    protected void SecondPicLink_Click(object sender, ImageClickEventArgs e)
    {
        Session["yesID"] = Session["SecondyesId"];
        Session["noId"] = Session["SecondnoId"];
        //SecondPicLink.PostBackUrl = "default.aspx";
        //SecondPicLink.PostBackUrl = "GadgetFS.aspx?yesId=" + secondYesPicId + "&noId=" + secondNoPicId;
    }
  • 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-27T16:31:38+00:00Added an answer on May 27, 2026 at 4:31 pm

    What you are asking is illegal. There’s an order in which things are executed in ASP.NET

    • ASP.NET Page LifeCycle Overview

    As you can see “Postback event handling” happens after “Load” and trying to trick this, will cause you headaches afterwards. It’s a very bad practice and this is coming from someone who’s been down that road. You don’t want to mess with the page lifecycle.

    Looking at your code, I could suggest you put whatever should go in the // Run this code lines into a method, and call that method from the Click handlers, but not from the else block.
    Anyhow, you should always have the page lifecycle in mind, and revise your code logic according to that.

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

Sidebar

Related Questions

I have two models, Image and Tag . Each Image object can have more
I am having dependency troubles. I have two classes: Graphic and Image . Each
Everybody.. How to set animation on button click ? I have two buttons, both
i have two buttons in menu on mouse over the button change image to
I have an image gallery with say 39 number of images. Two buttons prev
Here is a simplified version of my database model. I have two tables: Image,
I have two models, Room and Image . Image is a generic model that
I have two BufferedImages I loaded in from pngs. The first contains an image,
I have two methods, one that I use to convert an image to a
I have two side borders on my website, left and right side... small image

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.