473,405 Members | 2,261 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,405 software developers and data experts.

Page_Load executes before aspx is rendered?

This might have been discussed before, but I haven't been able to dig
it out.

I ask because I notice something interesting.

Suppose, I have the following controls in a web form.

<asp:DropDownList ID="DropDownList1" runat="server" </
asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Suppose, in Page_Load, I want to do:

Label1.Text = DropDownList1.SelectedItem.Text;

If I bind the DropDownList right in the aspx file through
SqlDataSource, Label1.Text is empty when I check out the application
in the browser.

If I bind the DropDownList in the code behind, and in Page_Load, I do:

BindTheDropDownList();
Label1.Text = DropDownList1.SelectedItem.Text;

Label1.Text does have the text value of the 0th item of the
DropDownList.

Therefore, I think that at Page_Load, the binding processes in the
ASPX file are not done yet. Am I right?

Thanks.
Jan 30 '08 #1
3 1236
Yes. The binding of this sort takes place in the PreRender event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"gnewsgroup" <gn********@gmail.comwrote in message
news:eb**********************************@f10g2000 hsf.googlegroups.com...
This might have been discussed before, but I haven't been able to dig
it out.

I ask because I notice something interesting.

Suppose, I have the following controls in a web form.

<asp:DropDownList ID="DropDownList1" runat="server" </
asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Suppose, in Page_Load, I want to do:

Label1.Text = DropDownList1.SelectedItem.Text;

If I bind the DropDownList right in the aspx file through
SqlDataSource, Label1.Text is empty when I check out the application
in the browser.

If I bind the DropDownList in the code behind, and in Page_Load, I do:

BindTheDropDownList();
Label1.Text = DropDownList1.SelectedItem.Text;

Label1.Text does have the text value of the 0th item of the
DropDownList.

Therefore, I think that at Page_Load, the binding processes in the
ASPX file are not done yet. Am I right?

Thanks.

Jan 30 '08 #2
On Jan 30, 10:59*am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Yes. The binding of this sort takes place in the PreRender event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
Thank you. I think by "binding of this sort", you are referring to
the kind of binding in aspx file through SqlDataSource?
Jan 30 '08 #3
Yes.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"gnewsgroup" <gn********@gmail.comwrote in message
news:0d**********************************@s8g2000p rg.googlegroups.com...
On Jan 30, 10:59 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Yes. The binding of this sort takes place in the PreRender event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
Thank you. I think by "binding of this sort", you are referring to
the kind of binding in aspx file through SqlDataSource?
Jan 30 '08 #4

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

Similar topics

0
by: Andreas Klemt | last post by:
Hello, I have an ASPX Page with 8 Web User Controls on it. Some are Visible = False and some are Visible = True Now I wrote in each Web User Control code: Sub Page_Load() If Me.Visible...
1
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes...
4
by: Guadala Harry | last post by:
Just wondering what could cause this: I have observed that when first opening an aspx page, the Page_Load event fires as expected. Then I go to other pages in the site. When returning to any page...
9
by: Hasani \(remove nospam from address\) | last post by:
I have a website with 2 aspx pages Foo.aspx, and bar.aspx The content of both files is //in 1 file Hello <%=Session.ToString()%> ================
5
by: ajholme | last post by:
We have a problem in our application: if a user clicks a link to load another page before the previous ASPX has finished executing, the Sub New() constructor of the second page executes...
2
by: John Dalberg | last post by:
I need to know what happens after Page_load has finished so I put a breakpoint at the last statement. However after stepping into after this last statement, the app continues running without the...
17
by: Arpan | last post by:
When a Button is clicked in a Web Form in an ASPX page, the Form will post back to itself. Under such circumstances (i.e. when a Button is clicked), will the Page_Load sub execute first & then will...
3
by: dotNET learner | last post by:
In the following aspx file the output from Page_Load code is rendered first and HTML later. I want the other way round. How can I do that? <%@ Page Language="C#" %> <%@ Import...
1
by: epower | last post by:
Hello, I am working on an ASP .NET application in Visual Studio 2005 and running IE7. This application has a page that contains an iframe which loads an .aspx page and hyperlinks that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.