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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:09:17+00:00 2026-05-31T20:09:17+00:00

i got a page where the admin can edit some photos i pull from

  • 0

i got a page where the admin can edit some photos i pull from flickr so all the controls are added Dynamiclly.

i have few controls i add to a panel and then add the panel to Form.Controls.
all the data thay are holding come from flickr.

my problem is that, afther a post back the list change and the controls are loading, BUT the Text Box’s keep that same data befor the post back even though i get the data from flickr every time.

what wierd for my that if i do this with less textbox every thing work fine.
the list are about 10+ pictures and this numbers can change in the future.

(sorry for the messy code im pretty new to programming)
here is the code:

protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            RadioButtonList1.AutoPostBack = true;

            selectedSetID = getSelectedSetId(RadioButtonList1.SelectedItem.Text);

            photoSet = new MyPhotoSet(selectedSetID);
            photo = new FlickerImages[photoSet.Count];

            for (int j = 0; j < photo.Length; j++)
            {
                photo[j] = new FlickerImages(photoSet.MediumURLS[j], photoSet.ThumbnailURLS[j],                                 photoSet.Titles[j], photoSet.Descreption[j], photoSet.PhotosID[j]);

                panel = photo[j].GetPanelWithEditControls(j);

                button = new Button();
                button.ID = "sendDataButton" + j;
                button.Text = "send data";
                button.Click += button_Click;

                panel.Controls.Add(button);
                Form.Controls.Add(panel);
            }

        }
        else
        {
                 //here is the post back,
 every thing load fine.
 adding and removing the controls but if the textbox's load in the same place, it hold the same data befor the post back.

            RadioButtonList1.AutoPostBack = true;
            selectedSetID = getSelectedSetId(RadioButtonList1.SelectedItem.Text);

            photoSet = new MyPhotoSet(selectedSetID);
            photo = new FlickerImages[photoSet.Count];

            for (int i = 0; i < photo.Length; i++)
            {
                photo[i] = new FlickerImages(photoSet.MediumURLS[i], photoSet.ThumbnailURLS[i],                                     photoSet.Titles[i], photoSet.Descreption[i], photoSet.PhotosID[i]);

                panel = photo[i].GetPanelWithEditControls(i);

                button = new Button();
                button.ID = "sendDataButton" + i;
                button.Text = "send data";
                button.Click += button_Click;

                panel.Controls.Add(button);
                Form.Controls.Add(panel);
            }

        }
    }

(sorry for my english)

  • 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-31T20:09:18+00:00Added an answer on May 31, 2026 at 8:09 pm

    Instead of putting your control generation in Page_Load, put it in Page_Init.

    Since you mentioned that you’re pretty new to ASP.NET, I strongly recommend reading up on the Page Lifecycle.

    As an ASP.NET developer, it’s very important that you understand how and when certain things happen on the server in between the time the server receives a request for an aspx page, and the time the page is output to be rendered by the browser.

    The short explanation for why I suggest putting the code in Page_Init is how the runtime deals with dynamically created controls and Viewstate. The Viewstate contains any changes made by the user of your web app. In the page lifecycle, you’ll notice that the application of Viewstate values happen before Page_Load, but after Page_Init.

    This means that if your code in in Page_Load, then the controls are generated from Viewstate, updated with what the user put in, but then your own code in page_Load is re-generating those controls with the default values. There’s nothing that happens after this event that can re-load the user’s input.

    (Hopefully that makes sense. If not, the page I linked to may explain it better.)

    There’s another article on here that addresses the subject from a different angle, but still should be very helpful for you.

    And there’s the ultra-short version here.

    And finally, (saving the best for last) one of the most comprehensive articles on the subject that explains things in plain English can be found here.

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

Sidebar

Related Questions

Under Pages menu in Wordpress Admin page, I got this layout: Pages Edit (url:
All, I've got a page that I'm an admin for on Facebook and I've
i got a page users downloading files from there.And when a user click download
I've got a page with a normal form with a submit button and some
I've got a page where I'm dynamically adding elements to a from a series
I've got a page that retrieves a bunch of locations and some data about
I want to retrieve the JSON from http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34 but I can't seem to get
I have got this project that uses excel for some calculation. This excel is
I've essentially got two tables: Page(PK=url) and PageProperty(PK=url+name). Here is how I have my
I have to fill in multiple form fields on a web page I got

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.