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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:53:05+00:00 2026-06-11T05:53:05+00:00

I have two buttons with on click functions The 1st one gets assigned a

  • 0

I have two buttons with on click functions

The 1st one gets assigned a variable when Clicked.

How do I get my second button to get the variable from the 1st button when I click button 2?

It doesn’t seem to work. As the second button doesn’t recognise the Variable.

Thanks

EDIT:

Just to clarify My code is generating a pdf. button 1 selects the url of the template to use. and in button 2 (the one generating the pdf) I want it to get the variable set from button 1 so it knows what template to use.

EDIT 2:
My code does work but only when I’m not using the ajax update panel. it seems that the variable I’m trying to set doesn’t get set with AJAX

  • 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-11T05:53:07+00:00Added an answer on June 11, 2026 at 5:53 am

    Your Button have Id, you get this button with his Id

    Nota : You can add runat=”server” in order to visualize in server side

    <asp:Button id="Button1"
               Text="Click "
               OnClick="Btn1_Click" 
               runat="server"/>
    
    <asp:Button id="Button2"
               Text="Click "
               OnClick="Btn2_Click" 
               runat="server"/>
    
    void Btn2_Click(Object sender, EventArgs e)
    {
        Button1.Text = "test after click on button 2";
    
        Template = ...;//Set your value
    }
    
    
    void Btn1_Click(Object sender, EventArgs e)
    {
        Button2.Text = "test after click on button 1";
    
        //Here you can get your value after post.
        var result = Template; 
    }
    

    It’s not subject but in delegate you can also get objet button by passing on sender argument.

    var button = sender as Button; //You get button who raise event
    

    In order to manage Template Path property.

    public string Template
    {
       get
       {
          if(ViewState["Template"] != null)
          {       
             return (string)ViewState["Template"];
          }
       }
    
       set{ViewState["Template"] = value;} 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two buttons that have assigned two functions, one by a broad selection:
I have two buttons, one of class button white and another one of class
I have two image buttons with Click events assigned to them. There is code
I have a form with two buttons. I check which one is clicked at
I have two hidden radio buttons and one visible button. Clicking this button should
I have two buttons, which the user can click and will open a FileDiagloag
I have two event handlers wired up to a button click in a Windows
I have two button name A, and B want to click them equal to
I have two tables on a webform. On a button click I want to
I have a custom ListView with two button and I when I click either

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.