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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:29:03+00:00 2026-05-18T23:29:03+00:00

I have page and call method inside my page. I want to add some

  • 0

I have page and call method inside my page. I want to add some control to my page Control (not page itself) inside that method.

My Default.aspx :

<%@ Page Title="Home Page" MasterPageFile="~/Site.master"  ...  %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</asp:Content>

and Code Behind :

namespace Program
{
    public partail class Default : Page
    {
         protected void Page_Load(object sender, Eventargs e)
         {
              MyClass.Calling(this); 
         }
    }
}

my another class

namespace Program
{
    public class MyClass
    {
         public static void Calling(Page page)
         {
              Textbox txt = new Textbox()
              // I want somthing like this:
              // page.PlaceHolder1.Controls.Add(txt);
         }
    }
}

Is this possible?

Update: Thanks to @The King.

  • 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-18T23:29:04+00:00Added an answer on May 18, 2026 at 11:29 pm

    I’m sorry about my previous answers not working to you.. I just wrote it from my memory… Here is a working solution… You first need to find the content place holder before finding your place holder…

    Note : Please use ContentPlaceHolderID and not the ID of the Content Tag…

    namespace Program  
    {  
        public class MyClass  
        {  
             public static void Calling(Page page)  
             {  
                ContentPlaceHolder cph = page.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;
                if (cph == null)
                {
                      return;
                }
    
                PlaceHolder ph = cph.FindControl("PlaceHolder1") as PlaceHolder;
                if (ph != null)
                {
                    ph.Controls.Add(new TextBox());
                }
             }  
        }  
    }  
    

    Please refer to the revision history for my old answers…

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

Sidebar

Related Questions

I have jquery with class= modal i want to call that class when page
I have a method inside of a MooTools class that I want to access
I have a Web page within my application that needs to call a web
I have a UserControl that I want to include in a page multiple times
I have a problem with ViewState. I have an aspx page that has a
I have a multiview on my ASPX page whose ActiveViewIndex I want to set
I have an issue while using buttons inside form. I want that button to
I have a helper method inside my App_Code folder which returns some html to
I have several pages that call in content via jQuery .ajax. I dont want
I have a main page from where I am making a call to load

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.