Page_Load vs Submit_Click - which one first?

Discussion in 'ASP .Net' started by Neo Geshel, Mar 21, 2006.

  1. Neo Geshel

    Neo Geshel Guest

    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.
    ***********************************************************************
     
    Neo Geshel, Mar 21, 2006
    #1
    1. Advertising

  2. 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" <> 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.
    ***********************************************************************
     
    Marina Levit [MVP], Mar 21, 2006
    #2
    1. Advertising

  3. Neo Geshel

    Neo Geshel Guest

    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.
    ***********************************************************************
     
    Neo Geshel, Mar 21, 2006
    #3
  4. Neo Geshel

    Neo Geshel Guest

    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.
    ***********************************************************************
     
    Neo Geshel, Mar 21, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bminder
    Replies:
    1
    Views:
    2,212
    nfedin
    Feb 23, 2004
  2. z. f.
    Replies:
    0
    Views:
    589
    z. f.
    Oct 19, 2004
  3. Patrick Olurotimi Ige

    Having 2 SUBMIT_CLICK buttons on a page?

    Patrick Olurotimi Ige, Jan 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    378
    Patrick Olurotimi Ige
    Jan 28, 2005
  4. =?Utf-8?B?T2JpIE9iZXJvaQ==?=

    Submit_click event fires only the first time the button is clicked

    =?Utf-8?B?T2JpIE9iZXJvaQ==?=, Sep 1, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    617
    Kevin Spencer
    Sep 1, 2005
  5. =?Utf-8?B?QW5kcmV3?=

    Which Page_Load event is raised first?

    =?Utf-8?B?QW5kcmV3?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,091
    Karl Seguin [MVP]
    Jan 20, 2006
Loading...

Share This Page