473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Loadpostdata of dynamically created controls in ASP.NET

1. Can anyone explain ,when Load post data event of a webservercontrol executes ,if it is created in pageload instead of init?[asp.net,C#]

2.My requirement was to create a textbox dynamically based on some contitions.so i created it in pageload.when the page is posted back(using a submit button) i am able to access user entered data in my dynamically created text box in submitbtn_click event.
I didnot understand the reason ,why i am able to access user entered data in my dynamically created text box, when i am creating it in page load which occurs after Load post data event .[asp.net,C#]
Mar 23 '07 #1
10 3081
DeMan
1,806 1GB
hi knknknkn,

Welcome to theScripts. You will find better responses to questionsd such as these in the various forums where the experts hang out (which you'll find on the Right Hand Side of the screen). I am moving this post to the .NET forum for you now....
Mar 23 '07 #2
hi knknknkn,

Welcome to theScripts. You will find better responses to questionsd such as these in the various forums where the experts hang out (which you'll find on the Right Hand Side of the screen). I am moving this post to the .NET forum for you now....

ok thanks DeMan
Mar 24 '07 #3
kenobewan
4,871 Expert 4TB
Code is executed line by line, so as long the textbox is created in the code before any event is executed and the users have an opportunity to fill in then it works. As the click event is executed and the textboxes exist when called there is no problem. If you are still interested in the finer details, this article may help:
ASP.NET Page Life Cycle Overview
Mar 26 '07 #4
thanks for ur response kenobewan,but i did not make out any thing of ur response.do u mean that ,the textbox which i created dynamically in pageload will cause the loadpostdata event of the page to be called again .i am working on
.net1.1,c#.
Mar 26 '07 #5
Frinavale
9,735 Expert Mod 8TB
thanks for ur response kenobewan,but i did not make out any thing of ur response.do u mean that ,the textbox which i created dynamically in pageload will cause the loadpostdata event of the page to be called again .i am working on
.net1.1,c#.
Hello there,

When the user first visits your website the PageLoad() method is called.
Here your textbox is dynamically created and is displayed in your user's web-browser.

The user is then able to enter information into the textbox and submit the form.
All of the values on the page are then sent to the server and the PageLoad() is called again. Since all of the values have been submitted you can access them in PageLoad or any other method in your web application.

Once the PageLoad() happens, the event handler code for your submit button is called...remember that all of the information from the form (including the information in the textbox) has already been submitted to your web-application...this is why you can access the user's information here.

Does this help at all?

-Frinny
Mar 26 '07 #6
Hello Frinavale,in which stage does the valu of TEXTBOX.TEXT PROPERTY Set to the value entered by the user(I think it should happen in LOADPOSTDATA Event .but in my case ,before i created the textbox this event is over).
But i am still able to access this value .so where or in which event is this text property of textbox being set.
Mar 28 '07 #7
Frinavale
9,735 Expert Mod 8TB
Hello Frinavale,in which stage does the valu of TEXTBOX.TEXT PROPERTY Set to the value entered by the user(I think it should happen in LOADPOSTDATA Event .but in my case ,before i created the textbox this event is over).
But i am still able to access this value .so where or in which event is this text property of textbox being set.
Hi there!

I'm just going to quickly review the page life cycle:
================================================== =======
Page Request
ASP.Net figures out if the page needs to be parsed/compiled or if there is a cached version of your website that can be sent back to the user without "Running" the page.

Start
The page properties Request and Response are set and it is determined whether the request is postback or not.

****Page Initialization
Your controls are set

Load
The OnLoad() event method is called for your main page and all of its childern

Validation
The validation for each input control is performed. The IsValid property is set, indicating if the input was valid or not

Postback Event
The method that handles the event that caused the postback is executed.

Rendering
The viewSate is saved and the page is rendered and saved into an output stream in order to send it to the browser.

Unload
This happens after the page has been sent to the browser ...the Request and Response objects are destroyed ...basically clean up happens
================================================== =======

During the Page Initialization stage the PreLoad() event handler is called to load the view state and set all of your controls....I believe your TextBox.Text value is set here.

Cheers!

-Frinny
Mar 28 '07 #8
i am creating my textbox dynamically in pageload which happens after the completion of view stateloading and post dataprocessing.In this situation the text box should never get a chance to involve in view stateloading and post dataprocessing.let me be more clear
===============================
pagelifecycle:
[ASP.NET 1.1]
i have added statically only one button and a label

1.First Request:
----------------------------
1.page_init.-->(button,label)
2.loadviewstate
3.loadpostdata
4.pageload.-------->Here i am creating my TextBox.
{
tb=new TextBox();
this.FindControl("Form1").Controls.Add(tb);
}
*
*
page_unload and sent to browser.

output in browser:
textbox appears along with button and label
------------------------------------------------------------
page posted back to server.
------------------------------------------------------------
************************************************** *******************
2.Second Request:
------------------------------
1.page_init.--------->all statically added controls initialised(button,label)

2.loadviewstate---->setting view state of statically added controls

3.loadpostdata----->setting user entered values of initialized controls
(user entered values in browser)
Note:here in my case ,the textbox is not yet created,so there is no scope for setting its textproperty.

4.pageload.-------->Here i am creating my TextBox.
private void Page_Load(object sender, System.EventArgs e)
{
//put user code to initialize the page here
tb=new TextBox();
this.FindControl("Form1").Controls.Add(tb);
}
----------
Note:here in post back after page load event i am able to get user entered value which i am retrieving it in btn1 _click shown below.
************************************************** **************************************
my doubt is how text property of the text box is being set when loadpostdata event is completed before its creation.************************************************** ****************************************
-----------
private void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text=tb.Text;

}

*
*
Mar 29 '07 #9
Frinavale
9,735 Expert Mod 8TB
i am creating my textbox dynamically in pageload which happens after the completion of view stateloading and post dataprocessing.In this situation the text box should never get a chance to involve in view stateloading and post dataprocessing.let me be more clear
===============================
pagelifecycle:
[ASP.NET 1.1]
i have added statically only one button and a label

1.First Request:
----------------------------
1.page_init.-->(button,label)
2.loadviewstate
3.loadpostdata
4.pageload.-------->Here i am creating my TextBox.
{
tb=new TextBox();
this.FindControl("Form1").Controls.Add(tb);
}
*
*
page_unload and sent to browser.

output in browser:
textbox appears along with button and label
------------------------------------------------------------
page posted back to server.
------------------------------------------------------------
************************************************** *******************
2.Second Request:
------------------------------
1.page_init.--------->all statically added controls initialised(button,label)

2.loadviewstate---->setting view state of statically added controls

3.loadpostdata----->setting user entered values of initialized controls
(user entered values in browser)
Note:here in my case ,the textbox is not yet created,so there is no scope for setting its textproperty.

4.pageload.-------->Here i am creating my TextBox.
private void Page_Load(object sender, System.EventArgs e)
{
//put user code to initialize the page here
tb=new TextBox();
this.FindControl("Form1").Controls.Add(tb);
}
----------
Note:here in post back after page load event i am able to get user entered value which i am retrieving it in btn1 _click shown below.
************************************************** **************************************
my doubt is how text property of the text box is being set when loadpostdata event is completed before its creation.************************************************** ****************************************
-----------
private void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text=tb.Text;

}

*
*
The web server takes all the input submitted to it and puts it into a Request Object which ASP.NET takes and sorts out before any processing happens. Your Textbox that was created last time and all the data it contains is stored in the Request object....and ASP.NET loads it into its Request property.

ASP.NET also uses a Cached version of the page to serve any requests that happen after the very first request is made. This means that even though you've created your Textbox in your PageLoad() it can still be initialized.
Mar 29 '07 #10
Hello Frinavale

if i assign my textbox id as "t1",then can u let me know how can i access it or its entered value form requestobject on post back
Mar 30 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Burke | last post by:
I am getting a curious problem where LoadPostData is not being called after registering the control using RegisterRequiresPostback. Other controls not requiring postback registration are having...
2
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
0
by: tksc234 | last post by:
Hello there. My question is related to full custom server controls. 1) The 'input' element that caused the postback already has 'Me.UniqueID' in its name field. I assumed, the value of postDataKey...
5
by: Nathan Sokalski | last post by:
I am writing a Control that inherits from System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control renders more than just one inner Control. When a postback occurs, I need to get...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
0
by: Nathan Sokalski | last post by:
I have a custom control that inherits CompositeControl implements IPostBackDataHandler and ICallbackEventHandler. In the LoadPostData function, I attempt to use the PostCollection parameter to get...
0
by: Nathan Sokalski | last post by:
I have a custom control that inherits CompositeControl implements IPostBackDataHandler and ICallbackEventHandler. In the LoadPostData function, I attempt to use the postCollection parameter to get...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.