472,782 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

Programatically Declared User Control with Post Back

DM
I have a user control that contains a DropDownList and a Submit Button. In the Page_Load method of the User Control, I populate the Drop Down List. When the user clicks on the submit button, I need to retrieve the SelectedValue of the User Control. The code for populating the DropDownList should only run when the page is initialized, so I wrapped the code with if(!IsPostBack)

Everything works as expected when I declaratively add the control to a Page, but when I Programmatically add the control, I lose the ViewState for the DropDownList on the PostBack. Do I need to do something differently to be able to add the user control programmatically vs. declaratively
Nov 18 '05 #1
1 1530
one
This article should help you: http://msdn.microsoft.com/msdnmag/is.../03/visualprog

HTH
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Melissa | last post by:
What is the code to delete a command button from a form? Can the code be run from the click event of the button to be deleted? Thanks! Melissa
3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
7
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control...
4
by: Andrea Williams | last post by:
Does anyone know of some in depth documentation regarding how to add user controls programatically? I have a User Control, which has some basic html controls, and depending on the number selected...
1
by: DM | last post by:
I have a user control that contains a DropDownList and a Submit Button. In the Page_Load method of the User Control, I populate the Drop Down List. When the user clicks on the submit button, I need...
1
by: DotNetJunkies User | last post by:
Hi, I was wondering if it is possible to load datagrid into datalist programatically using ITemplate interface with the following structure and place intp placeholder control. PlaceHolder -...
2
by: P. Gruenhagen | last post by:
I've written several UserControls that contain different versions of a form that users need to fill out. Depending on which role a user is logged in as, I load the appropriate UserControl and add...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
1
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.