473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

AddressOf Operator and IsPostback

RA
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I
don't have IsPostBack check; I am able to debug through btnAdd_Click.
If I don't look for IsPostBack then it re-populates the table before doing
anything; which I don't want.

Following is the code.
private sub page_load(.......)
'
if ispostback = false then
populatetable
end if
End sub

private sub populatetable()
' besides other data, there is a button has been added to a TableCell of a
TableRow and for that button I also have following line 'of code
btnAdd.CommandName = "TableInfo"
AddHandler btnAdd.Command, AddressOf btnAdd_Click
end sub

Public Sub btnAdd_Click(ByVal sender As Object, e As _
System.EventArgs)
' code here, when "Add" button is clicked
End Sub

would really appreciate any help on this


Nov 18 '05 #1
6 1434
Your event needs to be hooked up on postback...forgetting about
populatetable for now, in reality all you need is:

dim btn as new Button()
if Page.IsPostBack then
AddHandler btn.Click, AdressOf ...
end if

what you are doing is the opposite - only hooking the event when it isn't
postback.

You should call populatetable() again - I realize that isn't what you want
to hear. You might be able to avoid it by looking at Request.Form and
seeing which button was clicked and then calling the function directly.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I don't have IsPostBack check; I am able to debug through btnAdd_Click.
If I don't look for IsPostBack then it re-populates the table before doing
anything; which I don't want.

Following is the code.
private sub page_load(.......)
'
if ispostback = false then
populatetable
end if
End sub

private sub populatetable()
' besides other data, there is a button has been added to a TableCell of a
TableRow and for that button I also have following line 'of code
btnAdd.CommandName = "TableInfo"
AddHandler btnAdd.Command, AddressOf btnAdd_Click
end sub

Public Sub btnAdd_Click(ByVal sender As Object, e As _
System.EventArgs)
' code here, when "Add" button is clicked
End Sub

would really appreciate any help on this

Nov 18 '05 #2
Hi RA,
The problem is with the position where you adding the btnAdd_Click from.
Remember if you use "if ispostback = false then" --> this means, execute
the following code only when the page loads for the first time. So, you are
calling populatetable() only the first time the page loads. In this method,
you are adding the event handler to the "click" event. Thats good. Now the
page postbacks, this code doesnt get executed, so there is no event handler
added for the button click. You see the point here. Web applications are
stateless. All the controls or variables are repopulated each time your page
postbacks.
So, the code is not preserved during postbacks. thats why you are losing
that event handler, when the page postbacks. So, you should move the code
that adds event handler outside the populatetable() method, or call this
method on postback.

HTH
Kumar

"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I don't have IsPostBack check; I am able to debug through btnAdd_Click.
If I don't look for IsPostBack then it re-populates the table before doing
anything; which I don't want.

Following is the code.
private sub page_load(.......)
'
if ispostback = false then
populatetable
end if
End sub

private sub populatetable()
' besides other data, there is a button has been added to a TableCell of a
TableRow and for that button I also have following line 'of code
btnAdd.CommandName = "TableInfo"
AddHandler btnAdd.Command, AddressOf btnAdd_Click
end sub

Public Sub btnAdd_Click(ByVal sender As Object, e As _
System.EventArgs)
' code here, when "Add" button is clicked
End Sub

would really appreciate any help on this

Nov 18 '05 #3
RA
I got your point about AddressOf Operator.

But as long as populating table is concerned, shouldn't it hold the data in
the table even if it is postback?
I see it holds data for a lable.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uC**************@TK2MSFTNGP11.phx.gbl...
Your event needs to be hooked up on postback...forgetting about
populatetable for now, in reality all you need is:

dim btn as new Button()
if Page.IsPostBack then
AddHandler btn.Click, AdressOf ...
end if

what you are doing is the opposite - only hooking the event when it isn't
postback.

You should call populatetable() again - I realize that isn't what you want
to hear. You might be able to avoid it by looking at Request.Form and
seeing which button was clicked and then calling the function directly.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load.
If

I
don't have IsPostBack check; I am able to debug through btnAdd_Click.
If I don't look for IsPostBack then it re-populates the table before
doing
anything; which I don't want.

Following is the code.
private sub page_load(.......)
'
if ispostback = false then
populatetable
end if
End sub

private sub populatetable()
' besides other data, there is a button has been added to a TableCell of
a
TableRow and for that button I also have following line 'of code
btnAdd.CommandName = "TableInfo"
AddHandler btnAdd.Command, AddressOf btnAdd_Click
end sub

Public Sub btnAdd_Click(ByVal sender As Object, e As _
System.EventArgs)
' code here, when "Add" button is clicked
End Sub

would really appreciate any help on this


Nov 18 '05 #4
If you havent set the EnableViewState property to false, it does keep the
data. Be default this property is true, so ViewState stores all the data
about this control, so it gets preserved during postbacks

"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I got your point about AddressOf Operator.

But as long as populating table is concerned, shouldn't it hold the data in the table even if it is postback?
I see it holds data for a lable.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uC**************@TK2MSFTNGP11.phx.gbl...
Your event needs to be hooked up on postback...forgetting about
populatetable for now, in reality all you need is:

dim btn as new Button()
if Page.IsPostBack then
AddHandler btn.Click, AdressOf ...
end if

what you are doing is the opposite - only hooking the event when it isn't postback.

You should call populatetable() again - I realize that isn't what you want to hear. You might be able to avoid it by looking at Request.Form and
seeing which button was clicked and then calling the function directly.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load.
If

I
don't have IsPostBack check; I am able to debug through btnAdd_Click.
If I don't look for IsPostBack then it re-populates the table before
doing
anything; which I don't want.

Following is the code.
private sub page_load(.......)
'
if ispostback = false then
populatetable
end if
End sub

private sub populatetable()
' besides other data, there is a button has been added to a TableCell of a
TableRow and for that button I also have following line 'of code
btnAdd.CommandName = "TableInfo"
AddHandler btnAdd.Command, AddressOf btnAdd_Click
end sub

Public Sub btnAdd_Click(ByVal sender As Object, e As _
System.EventArgs)
' code here, when "Add" button is clicked
End Sub

would really appreciate any help on this



Nov 18 '05 #5
RA
I have not set the table's EnableViewState property to False; even though it
loses data.
Is it because I am populating table dynamically(TableRow and TableCell)?
Should I set their (TableRows' and TableCells') EnableViewState Property to
true programatically?

"Kumar Reddi" <Ku********@REMOVETHIS.gmail.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If you havent set the EnableViewState property to false, it does keep the
data. Be default this property is true, so ViewState stores all the data
about this control, so it gets preserved during postbacks

"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I got your point about AddressOf Operator.

But as long as populating table is concerned, shouldn't it hold the data

in
the table even if it is postback?
I see it holds data for a lable.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uC**************@TK2MSFTNGP11.phx.gbl...
> Your event needs to be hooked up on postback...forgetting about
> populatetable for now, in reality all you need is:
>
> dim btn as new Button()
> if Page.IsPostBack then
> AddHandler btn.Click, AdressOf ...
> end if
>
> what you are doing is the opposite - only hooking the event when it isn't > postback.
>
> You should call populatetable() again - I realize that isn't what you want > to hear. You might be able to avoid it by looking at Request.Form and
> seeing which button was clicked and then calling the function directly.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "RA" <rc***************@storis.com> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
>> btnAdd_Click does not get hit; if I have IsPostBack check in
>> Page_load.
>> If
> I
>> don't have IsPostBack check; I am able to debug through btnAdd_Click.
>> If I don't look for IsPostBack then it re-populates the table before
>> doing
>> anything; which I don't want.
>>
>> Following is the code.
>> private sub page_load(.......)
>> '
>> if ispostback = false then
>> populatetable
>> end if
>> End sub
>>
>> private sub populatetable()
>> ' besides other data, there is a button has been added to a TableCell of >> a
>> TableRow and for that button I also have following line 'of code
>> btnAdd.CommandName = "TableInfo"
>> AddHandler btnAdd.Command, AddressOf btnAdd_Click
>> end sub
>>
>> Public Sub btnAdd_Click(ByVal sender As Object, e As _
>> System.EventArgs)
>> ' code here, when "Add" button is clicked
>> End Sub
>>
>> would really appreciate any help on this
>>
>>
>>
>>
>
>



Nov 18 '05 #6
ohh you are populating the TableRows and TableCells dynamically too, I didnt
know that. yeah they wouldnt be preserved either, even if you put their
EnableViewState to true. You should bind all these on every postback

"RA" <rc***************@storis.com> wrote in message
news:eH*************@TK2MSFTNGP11.phx.gbl...
I have not set the table's EnableViewState property to False; even though it loses data.
Is it because I am populating table dynamically(TableRow and TableCell)?
Should I set their (TableRows' and TableCells') EnableViewState Property to true programatically?

"Kumar Reddi" <Ku********@REMOVETHIS.gmail.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
If you havent set the EnableViewState property to false, it does keep the data. Be default this property is true, so ViewState stores all the data
about this control, so it gets preserved during postbacks

"RA" <rc***************@storis.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I got your point about AddressOf Operator.

But as long as populating table is concerned, shouldn't it hold the data
in
the table even if it is postback?
I see it holds data for a lable.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uC**************@TK2MSFTNGP11.phx.gbl...
> Your event needs to be hooked up on postback...forgetting about
> populatetable for now, in reality all you need is:
>
> dim btn as new Button()
> if Page.IsPostBack then
> AddHandler btn.Click, AdressOf ...
> end if
>
> what you are doing is the opposite - only hooking the event when it

isn't
> postback.
>
> You should call populatetable() again - I realize that isn't what you

want
> to hear. You might be able to avoid it by looking at Request.Form
and > seeing which button was clicked and then calling the function directly. >
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "RA" <rc***************@storis.com> wrote in message
> news:%2****************@TK2MSFTNGP09.phx.gbl...
>> btnAdd_Click does not get hit; if I have IsPostBack check in
>> Page_load.
>> If
> I
>> don't have IsPostBack check; I am able to debug through btnAdd_Click. >> If I don't look for IsPostBack then it re-populates the table before
>> doing
>> anything; which I don't want.
>>
>> Following is the code.
>> private sub page_load(.......)
>> '
>> if ispostback = false then
>> populatetable
>> end if
>> End sub
>>
>> private sub populatetable()
>> ' besides other data, there is a button has been added to a

TableCell of
>> a
>> TableRow and for that button I also have following line 'of code
>> btnAdd.CommandName = "TableInfo"
>> AddHandler btnAdd.Command, AddressOf btnAdd_Click
>> end sub
>>
>> Public Sub btnAdd_Click(ByVal sender As Object, e As _
>> System.EventArgs)
>> ' code here, when "Add" button is clicked
>> End Sub
>>
>> would really appreciate any help on this
>>
>>
>>
>>
>
>



Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Tim Clacy | last post by:
Am I correct in think that you can't re-assign a reference to a different object? If so, what should happen here: struct A { DoSomeThing(); }; A& GetNextA();
4
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each...
15
by: Patrick.O.Ige | last post by:
Hi All i'm getting error with my TreeView Menu(I want to have a button with ExpandALL and CollapseALL):- Error:- 'AddressOf' operand must be the name of a method; no parentheses are needed. I...
4
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal...
3
by: BoloBaby | last post by:
OK, here's the problem... I have a digital input/output card that exposes IRQs (digital input change-of-state) through a DLL function. In VB6.0, I can use this ability through code that looks...
1
by: peter | last post by:
Probably you might help me regarding this.. I'm new to these Vb.net language. My question is Does AddressOf is accepted in Vb.net? in this VbCode: I have this API...
3
by: owais | last post by:
I have one vb6 application in which it uses one variable Private m_wndprcNext and uses in SetWindowLong hWndCur, GWL_WNDPROC, m_wndprcNex one other calling of method is in same clas
5
by: David Lozzi | last post by:
Hello, I have an interesting issue, so bear with me as I try to explain. I have a datalist posing as tabs for my application. And as each tab is clicked, a placeholder is then populated with the...
1
by: Karl Rhodes | last post by:
I'm building a windows forms app in VB.net 2005 and would like to know if there is any way of adding a handler using a dynamic AddressOf value? The application will have a "Windows" menu item...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.