By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,288 Members | 3,027 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,288 IT Pros & Developers. It's quick & easy.

question about the events in the webform control

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <ha******@mail.hongkong.com> wrote in message
news:Oj*************@TK2MSFTNGP12.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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." <wf*********@kpmg.com> wrote in message
news:Op*************@TK2MSFTNGP11.phx.gbl...
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" <ha******@mail.hongkong.com> wrote in message
news:Oj*************@TK2MSFTNGP12.phx.gbl...
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


Nov 18 '05 #3

P: n/a
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" <ha******@mail.hongkong.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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." <wf*********@kpmg.com> wrote in message
news:Op*************@TK2MSFTNGP11.phx.gbl...
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" <ha******@mail.hongkong.com> wrote in message
news:Oj*************@TK2MSFTNGP12.phx.gbl...
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



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.