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

  • Home
  • SEARCH
  • 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 6255455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:22:05+00:00 2026-05-24T14:22:05+00:00

I have a dropdownlist (on Page) which has OnSelectedIndexChange event thats Loads different Control

  • 0

I have a dropdownlist (on Page) which has OnSelectedIndexChange event thats Loads different Control (ascx) dynamically each time ( with LoadControl Command) – into the page.

Each Control Has a Button(runat=server) and TextBox(runat=server).

When i click on the button – i cant get into the Onclick function .

How can i get into the OnClick Function of the Ascx ?

I know that each SelectedIndexChange its makes postback – so i know i have to save something in the viewstate. but i dont know how to save it and later get the values eneterd on the TexstBox. ( of Each ascx)

  • 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-24T14:22:06+00:00Added an answer on May 24, 2026 at 2:22 pm

    You need to add an event handler to the user control, like this:

    public event EventHandler ButtonClick;
    

    And in the click event of the button:

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.ButtonClick != null)
            this.ButtonClick(this, e);
    }
    

    Then, from the page, you can get the click event like this:

    <UC:MyUserControl ID="UserControl1" runat="server" OnButtonClick="UserControl1_ButtonClick" ... />
    
    protected void UserControl1_ButtonClick(object sender, EventArgs e)
    {
       //Handle the click event here
    }
    

    If you’re loading the controls dynamically, then you’ll need to make sure the controls are rehydrated after postback, and emulate the code above by assinging the event handler through code:

    MyUserControl ctrl = (MyUserControl)this.LoadControl("...");
    ctrl.ButtonClick += new EventHandler(UserControl1_ButtonClick);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which has an Html.DropDownList which takes in a viewdata parameter.
I have small page which has label, DropDownList and a submit button. <div> <asp:label
i have dropdownlist of year which is coming dynamically.i have filled the dropdownlist using
I have DropDownList, which has some options to choose from. Now after when user
I have two dropdownlist, a detailsview and a formview control in my page. The
I have a dropdownlist for which I am loading data from excel. Excel has
I have a page, it has a drop down list, which contains the names
I have a page which contains the generated content. Page.aspx: <asp:DropDownList ID=cmbUsers runat=server AutoPostBack=True
I have a page that has a few textboxes and a dropdownlist. When a
I have Dropdownlist on my page and its selectedindexchanged method created in code behind

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.