Hi,
In my ASPNet 2.0 C# web application Form1.aspx, there are 1 TextBox control
txtBox1, 1 Button control Btn1, and 1 GridView control GV1.
I found whenever I click the Button control Btn1, then the Page_Load event
will be called first.
This also applys to the situation when I check a CheckBox in the GV1.
I am wondering why in the aspx web form, whenever we click any controls,
they all call the Page_Load event?
Thanks for help.
Jason 5 1487
The page load will allways fire before any of the the events caused by
button pushes etc. It is a programatic requirement to be able to do things
at this time before other events load.
"Jason Huang" <Ja************ @hotmail.comwro te in message
news:ut******** ******@TK2MSFTN GP06.phx.gbl...
Hi,
In my ASPNet 2.0 C# web application Form1.aspx, there are 1 TextBox
control txtBox1, 1 Button control Btn1, and 1 GridView control GV1.
I found whenever I click the Button control Btn1, then the Page_Load event
will be called first.
This also applys to the situation when I check a CheckBox in the GV1.
I am wondering why in the aspx web form, whenever we click any controls,
they all call the Page_Load event?
Thanks for help.
Jason
Hi, Jason.
re:
!I found whenever I click the Button control Btn1, then the Page_Load event will be called first.
That's because you're POSTing the page when you click the button.
Please review the ASP.NET Page Lifecycle ... http://msdn2.microsoft.com/en-us/lib...72(VS.80).aspx
re:
!I am wondering why in the aspx web form, whenever we click any controls, they all call the Page_Load event?
Do you have autopostback set to "true" ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"Jason Huang" <Ja************ @hotmail.comwro te in message news:ut******** ******@TK2MSFTN GP06.phx.gbl...
Hi,
In my ASPNet 2.0 C# web application Form1.aspx, there are 1 TextBox control txtBox1, 1 Button control Btn1, and 1
GridView control GV1.
I found whenever I click the Button control Btn1, then the Page_Load event will be called first.
This also applys to the situation when I check a CheckBox in the GV1.
I am wondering why in the aspx web form, whenever we click any controls, they all call the Page_Load event?
Thanks for help.
Jason
The default behavior of a button control is to generate a postback. Other
controls can be set to generate a postback with their events (such as
TextChanged for textbox). A postback is nothing more than a form posting to
itself.
Page_Load always runs when a page is loaded, whether it is a postback or
not. Then, for any other events such as a button click, their event handler
code is run.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Jason Huang" wrote:
Hi,
In my ASPNet 2.0 C# web application Form1.aspx, there are 1 TextBox control
txtBox1, 1 Button control Btn1, and 1 GridView control GV1.
I found whenever I click the Button control Btn1, then the Page_Load event
will be called first.
This also applys to the situation when I check a CheckBox in the GV1.
I am wondering why in the aspx web form, whenever we click any controls,
they all call the Page_Load event?
Thanks for help.
Jason
"Jason Huang" <Ja************ @hotmail.comwro te in message
news:ut******** ******@TK2MSFTN GP06.phx.gbl...
I found whenever I click the Button control Btn1, then the Page_Load event
will be called first.
In addition to the other responses, you can use the IsPostBack property of
the Page object to determine whether your code within the Page_xxx events
runs or not...
if (!IsPostBack)
{
// run when the page first loads
}
else
{
// run when the page posts back to itself
}
--
Mark Rae
ASP.NET MVP http://www.markrae.net
"Mark Rae [MVP]" <ma**@markNOSPA Mrae.netwrote in message
news:ue******** ******@TK2MSFTN GP03.phx.gbl...
"Jason Huang" <Ja************ @hotmail.comwro te in message
news:ut******** ******@TK2MSFTN GP06.phx.gbl...
>I found whenever I click the Button control Btn1, then the Page_Load event will be called first.
In addition to the other responses, you can use the IsPostBack property of
the Page object to determine whether your code within the Page_xxx events
runs or not...
if (!IsPostBack)
{
// run when the page first loads
}
else
{
// run when the page posts back to itself
}
--
Mark Rae
ASP.NET MVP http://www.markrae.net
Once more you have taught me something Mark. I just encountered this as
well and had to devise code to make things work as I wanted. I had a page
that could be invoked from another page and pass nothing, or from a url
click that involved passing four variables. This drove me crazy until I
figured out that the page load occurred first. Having IsPostBack would have
solved my problem in a hardened manner, rather than the kluge I put
together. Thanks.
Shelly This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim H |
last post by:
I coded my first asp form and attempted to display a text message from a component. The static text "Our component
says:" shows on the aspx page, but the text line from the component does not show. No errors are produced.
Can someone get me started down the right path with aspnet?
The two modules are shown below. The solution, less the .dll and .pdb files, can ge grabed at
http://psiprograms.com/Programs/HelloWorld.zip (about 16 Kb)....
|
by: dryer |
last post by:
I have a web app that runs fine on my local machine (W2K pro), but when ran on
Windows 2003 server there is a glitch. I have a function that writes an XML doc
to a directory, but I can't figure out what account the 2003 server is using. I
gave ASPNET write privilges to the directory, but get 'Access Denied' errors.
When I gave permmisions to 'Authenticated Users' it works fine. So I went
through the whole list of users and nothing would...
|
by: Miller Lee |
last post by:
Hello,
In my project, something really trouble me.
Let me describe it with an example.
I build a project called WaitMe, in this project, I build two page,
-----------------------------------------
Wait.aspx:
private void Page_Load(object sender, System.EventArgs e)
{
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(60));
|
by: PinoyDotnet |
last post by:
I am just starting 2.0, so I have this
In ASPNET 1.X there is a method called InitializeComponent() which
clearly wires in the Page_Load method to the Load event, like this:
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
|
by: Thiago Campos Pereira |
last post by:
I need a support of the staff of the Microsoft.
Since the beginning of the year I am working in the CFLCL (Company of the
sector of energy with more than 15000 employees).
I am trying to convince the CFLCL to adopt the DotNet as tool of Web
development, but for this, I have that to obtain the approval of the
security staff.
The problem is that the security staff is fanatic with Linux and want that
| |
by: Dariusz Tomon |
last post by:
Hi
How can I get url of page so taht I can pass it to string varaible.
I have got several urls in my IIS under one folder. I want to have one
default.aspx where code under it recognize which url is used by user and
then display appropriate data to that url (one url is about fashion, other
about law and so on). By means of recognition of url I can display
appropriate banners for example.
|
by: Kenny M. |
last post by:
Hi
I want to write de content of a variable from my asp net code into the Title
Bar of the Browser
each time I need to switch between those world (HTML-ASPNET) I suffer cause
I don’t have clear the boundaries in between
What alternatives do I have?
Where Can I find a good documentation about using or switching between HTML
|
by: Harlan Messinger |
last post by:
I installed the Northwind database in my SQL Server developer version,
added to the server logins, and in OSQL ran
use Northwind
GO
grant all to
GO
These executed without error. But my test page is being denied access.
|
by: Mich |
last post by:
Hi,
i'm building an web application for anonymous users. They can take a look in
the website, nothing more. In order to perform other actions, the anonymous
user must be logged. So i create an aspx page with the CreateUserWizard
control. The user can fill his username, password etc ....
My problem is: when an user fills everything and clicks on button "create an
account", nothing happens (no error, but no user account created).
I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |