Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page_Load vs Submit_Click - which one first?

Reply
Thread Tools

Page_Load vs Submit_Click - which one first?

 
 
Neo Geshel
Guest
Posts: n/a
 
      03-21-2006
Question:

During the execution of code, which one is looked at first; the
Page_Load, or the Submit_Click?

My problem arises when I specify a literal in the Page_Load, and attach
it to the page dynamically. When I assign it content in the Submit_Click
(say, a “update successful!” message), nothing shows up. Why? If the
Page_Load (or the Page_Init, neither works in my case) is supposed to
place content on the page prior to Submit_Click being fired, why won’t a
ltrlContent.Text = "some content" work from inside the Submit_Click if
the literal has been set in the Page_Load?

For example, the following (highly edited and cut down) code simply
doesn’t work:

Dim ltrlContent As New Literal()
Sub Page_Load(...)
...
myForm.Controls.Add(ltrlContent)
...
End Sub
Private Sub Submit_Click(...)
ltrlContent.Text = "Update Successful!"
End Sub

TIA
...Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.” *
* - Stephen F. Roberts *
************************************************** *********************
* “Anyone who believes in Intelligent Design (“creationism”) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.” - 99.99+% of Scientists *
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      03-21-2006
Are you sure Submit_Click is attached as the Click event handler to a
button? You didn't have a 'Handles Submit.Click' on there, I don't know if
that is just an omission or if it's actually not there.

Have you tried debugging into Submit_Click and seeing if it ever gets
called?

I suspect the handler is not being attached correctly.

"Neo Geshel" <(E-Mail Removed)> wrote in message
news:iKYTf.170058$B94.88432@pd7tw3no...
Question:

During the execution of code, which one is looked at first; the
Page_Load, or the Submit_Click?

My problem arises when I specify a literal in the Page_Load, and attach
it to the page dynamically. When I assign it content in the Submit_Click
(say, a "update successful!" message), nothing shows up. Why? If the
Page_Load (or the Page_Init, neither works in my case) is supposed to
place content on the page prior to Submit_Click being fired, why won't a
ltrlContent.Text = "some content" work from inside the Submit_Click if
the literal has been set in the Page_Load?

For example, the following (highly edited and cut down) code simply
doesn't work:

Dim ltrlContent As New Literal()
Sub Page_Load(...)
...
myForm.Controls.Add(ltrlContent)
...
End Sub
Private Sub Submit_Click(...)
ltrlContent.Text = "Update Successful!"
End Sub

TIA
....Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
* "I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours." *
* - Stephen F. Roberts *
************************************************** *********************
* "Anyone who believes in Intelligent Design ("creationism") is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* "Intelligent Design, on the other hand, has no evidence at all; not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms." - 99.99+% of Scientists *
************************************************** *********************
Mignon McLaughlin once said that "A nymphomaniac is a woman [who is] as
obsessed with sex as the average man." Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************


 
Reply With Quote
 
 
 
 
Neo Geshel
Guest
Posts: n/a
 
      03-21-2006
Marina Levit [MVP] wrote:
> Are you sure Submit_Click is attached as the Click event handler to a
> button? You didn't have a 'Handles Submit.Click' on there, I don't knowif
> that is just an omission or if it's actually not there.
>
> Have you tried debugging into Submit_Click and seeing if it ever gets
> called?
>
> I suspect the handler is not being attached correctly.
>


The handler is being attached correctly. I use the following:

AddHandler submit.Click, AddressOf Submit_Click

To connect the button to Submit_Click. The button is being attached to
the page in the following way:

Dim preview As New Button()
myForm.Controls.Add(preview)
AddHandler submit.Click, AddressOf Submit_Click
preview.id = "preview"
preview.Text = "Preview News Article"

TIA
...Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.” *
* - Stephen F. Roberts *
************************************************** *********************
* “Anyone who believes in Intelligent Design (“creationism”) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.” - 99.99+% of Scientists *
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
 
Reply With Quote
 
Neo Geshel
Guest
Posts: n/a
 
      03-21-2006
Neo Geshel wrote:
> Marina Levit [MVP] wrote:
>> Are you sure Submit_Click is attached as the Click event handler to a
>> button? You didn't have a 'Handles Submit.Click' on there, I don't
>> know if that is just an omission or if it's actually not there.
>>
>> Have you tried debugging into Submit_Click and seeing if it ever gets
>> called?
>>
>> I suspect the handler is not being attached correctly.
>>

>
> The handler is being attached correctly. I use the following:
>
> AddHandler submit.Click, AddressOf Submit_Click
>
> To connect the button to Submit_Click. The button is being attached to
> the page in the following way:
>
> Dim preview As New Button()
> myForm.Controls.Add(preview)
> AddHandler submit.Click, AddressOf Submit_Click
> preview.id = "preview"
> preview.Text = "Preview News Article"
>
> TIA
> ...Geshel


Whoops... that kinda pointed out my problem, no?

AddHandler *submit*.Click....
*preview*.id = ...

Thanks.
...Geshel
--
************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
* “I contend that we are both atheists. I just believe in one fewer *
* god than you do. When you understand why you dismiss all the other *
* possible gods, you will understand why I dismiss yours.” *
* - Stephen F. Roberts *
************************************************** *********************
* “Anyone who believes in Intelligent Design (“creationism”) is just *
* as ignorant, irrational and ill-educated as someone who believes *
* that the world is a flat disc, that the Sun circles the Earth or *
* that there really is a tooth fairy. Darwinism has an overwhelming *
* foundation of evidence that can be tested and reproduced. *
* *
* “Intelligent Design, on the other hand, has no evidence at all;not *
* one single shred of testable proof. As such, Intelligent Design is *
* Religious Mythology, and has no right whatsoever to be in our *
* Science classrooms.” - 99.99+% of Scientists *
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 PM
Submit_click event fires only the first time the button is clicked =?Utf-8?B?T2JpIE9iZXJvaQ==?= ASP .Net 1 09-01-2005 06:02 PM
Having 2 SUBMIT_CLICK buttons on a page? Patrick Olurotimi Ige ASP .Net 2 01-28-2005 03:13 AM
in VB.NET Page_load of a base class called after the derived class Page_load ? z. f. ASP .Net 0 10-19-2004 12:01 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM



Advertisments