Customer Server Control State vs Web Page State

Results 1 to 2 of 2

Thread: Customer Server Control State vs Web Page State

  1. #1
    Join Date
    Dec 1969

    Default Customer Server Control State vs Web Page State

    I would like to know if anyone can explain the following.<BR><BR>- Place a &#060;asp:ListBox on a .aspx page and load it in page_load.<BR>Something like this<BR>private void addItems(int x)<BR>{<BR>for (int z=0;z&#060;x;++z)<BR>{<BR>lb2.Items.Add("alotofstu ff" + z.ToString());<BR>}<BR>}<BR><BR>private void Page_Load(object sender, System.EventArgs e)<BR>{<BR>if (!Page.IsPostBack)<BR>{<BR>addItems(100);<BR>}<BR> }<BR><BR>add a custom control which derives from a ListBox and add a bunch of items similarly. The custom control is in autopostback mode.<BR><BR>private void addItems(int x)<BR>{<BR>for (int z=0;z&#060;x;++z)<BR>{<BR> this.Items.Add("alotofstuff" + z.ToString());<BR>}<BR>}<BR><BR>protected override void OnInit(EventArgs e)<BR>{<BR> this.EnableViewState=true;<BR> this.AutoPostBack=true;<BR> if (!Page.IsPostBack ) <BR> {<BR> addItems(100);<BR> }<BR> base.OnInit(e);<BR>}<BR><BR>Ok when you click on the custom control and it posts back the contents of the custom listbox are not refilled yet the one on the web page is. The million dollar question, not payable in legal tender :-) is WHY.<BR><BR>Thanks<BR><BR>Pete<BR>

  2. #2
    Join Date
    Dec 1969

    Default Looks like .NET - use forum <EOP>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts