question about the events in the webform control

Discussion in 'ASP .Net' started by Harry, May 10, 2004.

  1. Harry

    Harry Guest

    Dear all,

    It is found that when a webform control trigger an event,

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    End Sub

    This function will be load first, followed by

    Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Submit.Click
    End Sub

    the click event of button.

    I have to generate a table from the database table.

    I found that the generation of table function should put in submit_click
    function

    Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles Submit.Click
    displaytablefromdatabase()
    End Sub

    Also, i have to put the displaytablefromdatabase() function page_load as i
    have to deal with the postback when the page is refreshed.

    Thus, i added something in Page_load

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If me.ispostback() then
    displaytablefromdatabase()
    end if
    End Sub


    The problem is that, i have another button called "reset", if a user click
    "reset" button, the textbox in the form is set to empty string.

    however, each time the "reset" button has been click, it will autopost back
    and go to the "Page_Load" function and execute the
    displaytablefromdatabase() and display the form. before the form goes to
    "Reset_Click" function.

    Clearly, i don't want to execute displaytablefromdatabase() when i click
    Reset button. But, the webform has to go to Page_Load function before go to
    the "Reset_Click" function.

    What can i do?

    Thanks all

    Regards,
    Harry
     
    Harry, May 10, 2004
    #1
    1. Advertising

  2. If you have a !Page.IsPostBack in your page load. I don't know how the
    displaytablefromdatabase() is running before the Reset_Click method (event).

    Please clarify.


    "Harry" <> wrote in message
    news:...
    > Dear all,
    >
    > It is found that when a webform control trigger an event,
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > End Sub
    >
    > This function will be load first, followed by
    >
    > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Submit.Click
    > End Sub
    >
    > the click event of button.
    >
    > I have to generate a table from the database table.
    >
    > I found that the generation of table function should put in submit_click
    > function
    >
    > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles Submit.Click
    > displaytablefromdatabase()
    > End Sub
    >
    > Also, i have to put the displaytablefromdatabase() function page_load as i
    > have to deal with the postback when the page is refreshed.
    >
    > Thus, i added something in Page_load
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > If me.ispostback() then
    > displaytablefromdatabase()
    > end if
    > End Sub
    >
    >
    > The problem is that, i have another button called "reset", if a user click
    > "reset" button, the textbox in the form is set to empty string.
    >
    > however, each time the "reset" button has been click, it will autopost

    back
    > and go to the "Page_Load" function and execute the
    > displaytablefromdatabase() and display the form. before the form goes to
    > "Reset_Click" function.
    >
    > Clearly, i don't want to execute displaytablefromdatabase() when i click
    > Reset button. But, the webform has to go to Page_Load function before go

    to
    > the "Reset_Click" function.
    >
    > What can i do?
    >
    > Thanks all
    >
    > Regards,
    > Harry
    >
    >
     
    William F. Robertson, Jr., May 10, 2004
    #2
    1. Advertising

  3. Harry

    Harry Guest

    the displaytablefromdatabase() has been put in

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    If me.ispostback() then // if it is
    post back, displaytablefromdatabase() will be runned
    displaytablefromdatabase()
    end if
    End Sub

    if i don't execute displaytablefromdatabase() when whenever it post back,
    the table will disappeared when the page is post back.



    "William F. Robertson, Jr." <> wrote in message
    news:...
    > If you have a !Page.IsPostBack in your page load. I don't know how the
    > displaytablefromdatabase() is running before the Reset_Click method

    (event).
    >
    > Please clarify.
    >
    >
    > "Harry" <> wrote in message
    > news:...
    > > Dear all,
    > >
    > > It is found that when a webform control trigger an event,
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > End Sub
    > >
    > > This function will be load first, followed by
    > >
    > > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles Submit.Click
    > > End Sub
    > >
    > > the click event of button.
    > >
    > > I have to generate a table from the database table.
    > >
    > > I found that the generation of table function should put in submit_click
    > > function
    > >
    > > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles Submit.Click
    > > displaytablefromdatabase()
    > > End Sub
    > >
    > > Also, i have to put the displaytablefromdatabase() function page_load as

    i
    > > have to deal with the postback when the page is refreshed.
    > >
    > > Thus, i added something in Page_load
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > If me.ispostback() then
    > > displaytablefromdatabase()
    > > end if
    > > End Sub
    > >
    > >
    > > The problem is that, i have another button called "reset", if a user

    click
    > > "reset" button, the textbox in the form is set to empty string.
    > >
    > > however, each time the "reset" button has been click, it will autopost

    > back
    > > and go to the "Page_Load" function and execute the
    > > displaytablefromdatabase() and display the form. before the form goes to
    > > "Reset_Click" function.
    > >
    > > Clearly, i don't want to execute displaytablefromdatabase() when i click
    > > Reset button. But, the webform has to go to Page_Load function before go

    > to
    > > the "Reset_Click" function.
    > >
    > > What can i do?
    > >
    > > Thanks all
    > >
    > > Regards,
    > > Harry
    > >
    > >

    >
    >
     
    Harry, May 11, 2004
    #3
  4. I don't know how safe this is (I am sure it is plenty safe), but it is what
    I started doing for this situation.

    override the OnPreRender event for the page and before calling
    myBase.OnPreRender()

    c# code
    protected override void OnPreRender( EventArgs e )
    {
    DisplayTableFromDataBase();
    base.OnPreRender( e );
    }

    The display table will always run after the page_load and any postback
    events have fired.

    bill

    "Harry" <> wrote in message
    news:%...
    > the displaytablefromdatabase() has been put in
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > If me.ispostback() then // if it

    is
    > post back, displaytablefromdatabase() will be runned
    > displaytablefromdatabase()
    > end if
    > End Sub
    >
    > if i don't execute displaytablefromdatabase() when whenever it post back,
    > the table will disappeared when the page is post back.
    >
    >
    >
    > "William F. Robertson, Jr." <> wrote in message
    > news:...
    > > If you have a !Page.IsPostBack in your page load. I don't know how the
    > > displaytablefromdatabase() is running before the Reset_Click method

    > (event).
    > >
    > > Please clarify.
    > >
    > >
    > > "Harry" <> wrote in message
    > > news:...
    > > > Dear all,
    > > >
    > > > It is found that when a webform control trigger an event,
    > > >
    > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles MyBase.Load
    > > > End Sub
    > > >
    > > > This function will be load first, followed by
    > > >
    > > > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles Submit.Click
    > > > End Sub
    > > >
    > > > the click event of button.
    > > >
    > > > I have to generate a table from the database table.
    > > >
    > > > I found that the generation of table function should put in

    submit_click
    > > > function
    > > >
    > > > Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles Submit.Click
    > > > displaytablefromdatabase()
    > > > End Sub
    > > >
    > > > Also, i have to put the displaytablefromdatabase() function page_load

    as
    > i
    > > > have to deal with the postback when the page is refreshed.
    > > >
    > > > Thus, i added something in Page_load
    > > >
    > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles MyBase.Load
    > > > If me.ispostback() then
    > > > displaytablefromdatabase()
    > > > end if
    > > > End Sub
    > > >
    > > >
    > > > The problem is that, i have another button called "reset", if a user

    > click
    > > > "reset" button, the textbox in the form is set to empty string.
    > > >
    > > > however, each time the "reset" button has been click, it will autopost

    > > back
    > > > and go to the "Page_Load" function and execute the
    > > > displaytablefromdatabase() and display the form. before the form goes

    to
    > > > "Reset_Click" function.
    > > >
    > > > Clearly, i don't want to execute displaytablefromdatabase() when i

    click
    > > > Reset button. But, the webform has to go to Page_Load function before

    go
    > > to
    > > > the "Reset_Click" function.
    > > >
    > > > What can i do?
    > > >
    > > > Thanks all
    > > >
    > > > Regards,
    > > > Harry
    > > >
    > > >

    > >
    > >

    >
    >
     
    William F. Robertson, Jr., May 11, 2004
    #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. titof
    Replies:
    0
    Views:
    546
    titof
    Jul 24, 2003
  2. timmso
    Replies:
    1
    Views:
    542
    Alex Papadimoulis
    Dec 12, 2003
  3. =?Utf-8?B?bXN1aw==?=

    Using one webform to set a value on another webform

    =?Utf-8?B?bXN1aw==?=, Jul 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    506
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 12, 2006
  4. =?Utf-8?B?Vk1J?=

    Moving value from popup Webform to main Webform?

    =?Utf-8?B?Vk1J?=, Oct 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    607
    GroupReader
    Oct 9, 2006
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    409
    Chris
    Aug 30, 2005
Loading...

Share This Page