简体   繁体   中英

Dynamically adding user control in C# asp.net

I saw a few posts in here that got me pointed in the right direction, but I think my issue is unique.

I have a user control that I want to add every time the Add button is clicked. I got that part working by verifying the button was clicked on postback, incrementing a counter, then looping through the counter on Page_Load to add the controls to my placeHolder.

I have two challanges left.

  1. How do I hold the values that were previously entered into the user control?

  2. My control conatins a series of images that are based on user input. These images are affected by JavaScript functions inside he control. So let's say I am changing a default image called default.gif. This works fine for the first control added, but the

  1. You must ensure that your UserControls get the same ID on every postback. On that way you ensure that the ViewState loads correctly to retain values across postbacks and to trigger events
  2. You must provide more informations and code for your second part of the question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM