473,623 Members | 3,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global Variable

Hello,

I am declaring a variable in my aspx.vb code as follows:

Public Class catalogue
Public productid As String
Private Sub Page_Load
...

I have an image button where I call the following function:

Public Sub MyFunction(ByVa l sender As Object, ByVal e As
CommandEventArg s)

Response.Write( productid)
Response.Write( e.CommandName)

End Sub

I can see the e.CommandName value but not the productid.

Is not productid global the way I declare it?

Thanks,
Miguel

Nov 19 '05 #1
9 3128
If you use the productid in the same class you should see it. Post a small
workable sample so we can repro and Ill get abck to you.

Are you also sure productid has a value since you dont post about an error
being thrown ? ;)

Cheers,
Tom Pester
Hello,

I am declaring a variable in my aspx.vb code as follows:

Public Class catalogue
Public productid As String
Private Sub Page_Load
...
I have an image button where I call the following function:

Public Sub MyFunction(ByVa l sender As Object, ByVal e As
CommandEventArg s)

Response.Write( productid)
Response.Write( e.CommandName)
End Sub

I can see the e.CommandName value but not the productid.

Is not productid global the way I declare it?

Thanks,
Miguel

Nov 19 '05 #2
1) Keep in mind that ASP.NET pages are created and disposed each time there
is an HTTP request i.e. members won't persist from one HTTP request to the
next (as this is not the same object that will handle both requests)...

2) If you already know this, make sure you set productid before using it.
For example it could be because events are not happening in the order you
expect. How is the "ProductID" member intialized ?

--

Patrice

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> a écrit dans le message
de news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
Hello,

I am declaring a variable in my aspx.vb code as follows:

Public Class catalogue
Public productid As String
Private Sub Page_Load
...

I have an image button where I call the following function:

Public Sub MyFunction(ByVa l sender As Object, ByVal e As
CommandEventArg s)

Response.Write( productid)
Response.Write( e.CommandName)

End Sub

I can see the e.CommandName value but not the productid.

Is not productid global the way I declare it?

Thanks,
Miguel

Nov 19 '05 #3
> I can see the e.CommandName value but not the productid.

Where can you see it?

Also, you just might want to inherit System.Web.UI.P age in your class if you
expect any System.Web.UI.P age events (such as Page_Load) to fire.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
Hello,

I am declaring a variable in my aspx.vb code as follows:

Public Class catalogue
Public productid As String
Private Sub Page_Load
...

I have an image button where I call the following function:

Public Sub MyFunction(ByVa l sender As Object, ByVal e As
CommandEventArg s)

Response.Write( productid)
Response.Write( e.CommandName)

End Sub

I can see the e.CommandName value but not the productid.

Is not productid global the way I declare it?

Thanks,
Miguel

Nov 19 '05 #4
Hello,

I will try to describe my problem.

In my page I have 2 distinct regions:

1. Datagrid which show a list of all products.

2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
This will show the detailed information of a certain product.

So when I choose a datagrid record the function Product_Detail is called
and the Labels, Image and Image Buttons are filled with the right
productid.

I mentioned I have 3 ImageButtons in region 2 of the page. Why?
These buttons show image thumbnails and when clicked call the function
Zoom_Image which will show the right image in the ASP:Image.

When Zoom_Image runs it needs to know which productid is current used in
region 2. So everytime I click my datagrid I set the global variable
currentproducti d=productid clicked.

This way I when I press one of the image buttons the zoom function knows
which record is in use.

Does this make any sense?

Somewhere here the global variable currentproducti d.

Maybe my approach is wrong.

Any idea?

Thanks,
Miguel

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
I can see the e.CommandName value but not the productid.

Where can you see it?

Also, you just might want to inherit System.Web.UI.P age in your class if you
expect any System.Web.UI.P age events (such as Page_Load) to fire.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
Hello,

I am declaring a variable in my aspx.vb code as follows:

Public Class catalogue
Public productid As String
Private Sub Page_Load
...

I have an image button where I call the following function:

Public Sub MyFunction(ByVa l sender As Object, ByVal e As
CommandEventArg s)

Response.Write( productid)
Response.Write( e.CommandName)

End Sub

I can see the e.CommandName value but not the productid.

Is not productid global the way I declare it?

Thanks,
Miguel


Nov 19 '05 #5
Hi Miguel,

I'm still confused. Sorry. First, what exactly do you mean by "region?" In
Visual Studio.Net, a region is simply an organizational tool for use in
development, and has nothing to do with how an app works. In an ASP.Net
page, I have no idea what the word is supposed to represent.

Second, as I mentioned before, I saw some of your code, which defined a
class called "catalogue. " Here is a reproduction of the code you posted
initially:
> Public Class catalogue
> Public productid As String
> Private Sub Page_Load
> ...
Now, the Page_Load Sub leads me to believe that this class is somehow
supposed to be derived from System.Web.UI.P age, but there is no "Inherits"
statement that indicates that it does. So, part of my confusion extends from
that.

After the ellipse, you state:
> I have an image button where I call the following function:
>
> Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> CommandEventArg s)

I'm not at all sure of what this class has to do with your Page, if
anything. The variable (field) "productid" is a public field of the
"catalogue" class. So, since I don't know what's going on with regards to
that class, I can't figure out what exactly is going wrong.

I don't know where you "have" this image button. If it is a member of the
"catalogue" class, what again does it have to do with an ASP.Net Page class,
which you have talked about, but doesn't seem to appear anywhere in your
code?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello,

I will try to describe my problem.

In my page I have 2 distinct regions:

1. Datagrid which show a list of all products.

2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
This will show the detailed information of a certain product.

So when I choose a datagrid record the function Product_Detail is called
and the Labels, Image and Image Buttons are filled with the right
productid.

I mentioned I have 3 ImageButtons in region 2 of the page. Why?
These buttons show image thumbnails and when clicked call the function
Zoom_Image which will show the right image in the ASP:Image.

When Zoom_Image runs it needs to know which productid is current used in
region 2. So everytime I click my datagrid I set the global variable
currentproducti d=productid clicked.

This way I when I press one of the image buttons the zoom function knows
which record is in use.

Does this make any sense?

Somewhere here the global variable currentproducti d.

Maybe my approach is wrong.

Any idea?

Thanks,
Miguel

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
> I can see the e.CommandName value but not the productid.

Where can you see it?

Also, you just might want to inherit System.Web.UI.P age in your class if
you
expect any System.Web.UI.P age events (such as Page_Load) to fire.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
> Hello,
>
> I am declaring a variable in my aspx.vb code as follows:
>
> Public Class catalogue
> Public productid As String
> Private Sub Page_Load
> ...
>
> I have an image button where I call the following function:
>
> Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> CommandEventArg s)
>
> Response.Write( productid)
> Response.Write( e.CommandName)
>
> End Sub
>
> I can see the e.CommandName value but not the productid.
>
> Is not productid global the way I declare it?
>
> Thanks,
> Miguel
>

Nov 19 '05 #6
Hi,

Yes, I have to admit my explanation was confusing.

1. All the functions are in Class Catalogue.
2. Yes, class catalogue is derived from Inherits System.Web.UI.P age.
The class is in catalogue.aspx. vb. It has the code for
catalogue.aspx.

3. In my aspx page (HTML code) I have 2 div's:

A) DIV id="Products_Gr id"

DIV Products_Grid includes PRODUCTS datagrid which shows N
records.

The DataGrid has 3 database fields:
1 - [Image01]
2 - [Title]
3 - [Price]

B) DIV id="Product_Det ail"

In DIV Product_Detail I have:
1 - One ASP:Image - [Image01] database field by default. Full
Size.
2 - Three ASP:ImageButton s - 3 thumbnail images using the fields:
[Image01], [Image02], [Image03]
3 - Four ASP:Labels - [Title], [Description], [Price], [code]

4. My functions

A) Build_Grid()
Builds the PRODUCTS datagrid, binds it to data...

B) Change_Product( )
When a record in datagrid is pressed it changes all the ASP:Image,
ASP:ImageButton s and ASP:Labels in DIV Product_Detail.

Like a Master-Detail in the same page.

C) Change_Photo()
When an ASP:ImageButton is pressed it gets its value and change
the
URL of full size image displayed in ASP:Image in DIV
Product_Detail.

This is where I have the problem!

Change_Photo() receives the field to use from the ASP:ImageButton .
I am using e.CommandName.

Q: But what record is being displayed? What is its productid?
A: It is the same as last record pressed in the datagrid.
So my implementation is:
Change_Product( ) is called THEN:
Global variable CurrentProductI D = ProductID of row pressed in
datagrid.
Change Product_Detail Labels and Images values using this record
value.
Change_Photo() is called THEN Get new Thumbnail to show in ASP:Image (full size) from
e.CommmandName
Get CurrentProductI D
Change ASP:Image "Photo" using the 2 values.

Well, this might be confusing but it's nothing more then a master-detail
page in some page and in the detail part I have 3 thumbnails with a full
size feature for them.

Everything is working but when I click the image buttons it's like the
global variable CurrentProductI D is not available. I have no idea why.

Thanks,
Miguel






"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
Hi Miguel,

I'm still confused. Sorry. First, what exactly do you mean by "region?" In
Visual Studio.Net, a region is simply an organizational tool for use in
development, and has nothing to do with how an app works. In an ASP.Net
page, I have no idea what the word is supposed to represent.

Second, as I mentioned before, I saw some of your code, which defined a
class called "catalogue. " Here is a reproduction of the code you posted
initially:

> Public Class catalogue
> Public productid As String
> Private Sub Page_Load
> ...

Now, the Page_Load Sub leads me to believe that this class is somehow
supposed to be derived from System.Web.UI.P age, but there is no "Inherits"
statement that indicates that it does. So, part of my confusion extends from
that.

After the ellipse, you state:

I have an image button where I call the following function:
>
> Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> CommandEventArg s)

I'm not at all sure of what this class has to do with your Page, if
anything. The variable (field) "productid" is a public field of the
"catalogue" class. So, since I don't know what's going on with regards to
that class, I can't figure out what exactly is going wrong.

I don't know where you "have" this image button. If it is a member of the
"catalogue" class, what again does it have to do with an ASP.Net Page class,
which you have talked about, but doesn't seem to appear anywhere in your
code?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello,

I will try to describe my problem.

In my page I have 2 distinct regions:

1. Datagrid which show a list of all products.

2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
This will show the detailed information of a certain product.

So when I choose a datagrid record the function Product_Detail is called
and the Labels, Image and Image Buttons are filled with the right
productid.

I mentioned I have 3 ImageButtons in region 2 of the page. Why?
These buttons show image thumbnails and when clicked call the function
Zoom_Image which will show the right image in the ASP:Image.

When Zoom_Image runs it needs to know which productid is current used in
region 2. So everytime I click my datagrid I set the global variable
currentproducti d=productid clicked.

This way I when I press one of the image buttons the zoom function knows
which record is in use.

Does this make any sense?

Somewhere here the global variable currentproducti d.

Maybe my approach is wrong.

Any idea?

Thanks,
Miguel

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:

I can see the e.CommandName value but not the productid.

Where can you see it?

Also, you just might want to inherit System.Web.UI.P age in your class if
you
expect any System.Web.UI.P age events (such as Page_Load) to fire.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
Hello,
>
> I am declaring a variable in my aspx.vb code as follows:
>
> Public Class catalogue
> Public productid As String
> Private Sub Page_Load
> ...
>
> I have an image button where I call the following function:
>
> Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> CommandEventArg s)
>
> Response.Write( productid)
> Response.Write( e.CommandName)
>
> End Sub
>
> I can see the e.CommandName value but not the productid.
>
> Is not productid global the way I declare it?
>
> Thanks,
> Miguel
>



Nov 19 '05 #7
Thanks Miguel,

I think it's getting a lot clearer.

I'm a little fuzzy on what the exact sequence of PostBacks and data changing
is. Something changes the value of CurrentProductI d, I think. But what
persists that value across PostBacks? Remember that a Page class lasts for
the time it takes to process a Request. Afterwards, the class is destroyed,
and rebuilt with the next Request. That is why ViewState exists, to restore
the values of Controls after a PostBack. But I can't tell for sure whether
the value is set during one PostBack and read in another, or how you are
persisting this value across PostBacks.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Yes, I have to admit my explanation was confusing.

1. All the functions are in Class Catalogue.
2. Yes, class catalogue is derived from Inherits System.Web.UI.P age.
The class is in catalogue.aspx. vb. It has the code for catalogue.aspx.

3. In my aspx page (HTML code) I have 2 div's:

A) DIV id="Products_Gr id"

DIV Products_Grid includes PRODUCTS datagrid which shows N records.

The DataGrid has 3 database fields:
1 - [Image01]
2 - [Title]
3 - [Price]

B) DIV id="Product_Det ail"

In DIV Product_Detail I have:
1 - One ASP:Image - [Image01] database field by default. Full Size.
2 - Three ASP:ImageButton s - 3 thumbnail images using the fields:
[Image01], [Image02], [Image03]
3 - Four ASP:Labels - [Title], [Description], [Price], [code]

4. My functions

A) Build_Grid()
Builds the PRODUCTS datagrid, binds it to data...

B) Change_Product( )
When a record in datagrid is pressed it changes all the ASP:Image,
ASP:ImageButton s and ASP:Labels in DIV Product_Detail.

Like a Master-Detail in the same page.

C) Change_Photo()
When an ASP:ImageButton is pressed it gets its value and change the
URL of full size image displayed in ASP:Image in DIV Product_Detail.

This is where I have the problem!

Change_Photo() receives the field to use from the ASP:ImageButton .
I am using e.CommandName.

Q: But what record is being displayed? What is its productid?
A: It is the same as last record pressed in the datagrid.
So my implementation is:
Change_Product( ) is called THEN:


Global variable CurrentProductI D = ProductID of row pressed in datagrid.
Change Product_Detail Labels and Images values using this record value.
Change_Photo() is called THEN

Get new Thumbnail to show in ASP:Image (full size) from e.CommmandName
Get CurrentProductI D
Change ASP:Image "Photo" using the 2 values.

Well, this might be confusing but it's nothing more then a master-detail
page in some page and in the detail part I have 3 thumbnails with a full
size feature for them.

Everything is working but when I click the image buttons it's like the
global variable CurrentProductI D is not available. I have no idea why.

Thanks,
Miguel






"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
Hi Miguel,

I'm still confused. Sorry. First, what exactly do you mean by "region?"
In
Visual Studio.Net, a region is simply an organizational tool for use in
development, and has nothing to do with how an app works. In an ASP.Net
page, I have no idea what the word is supposed to represent.

Second, as I mentioned before, I saw some of your code, which defined a
class called "catalogue. " Here is a reproduction of the code you posted
initially:

>> > Public Class catalogue
>> > Public productid As String
>> > Private Sub Page_Load
>> > ...

Now, the Page_Load Sub leads me to believe that this class is somehow
supposed to be derived from System.Web.UI.P age, but there is no
"Inherits"
statement that indicates that it does. So, part of my confusion extends
from
that.

After the ellipse, you state:

>> > I have an image button where I call the following function:
>> >
>> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
>> > CommandEventArg s)

I'm not at all sure of what this class has to do with your Page, if
anything. The variable (field) "productid" is a public field of the
"catalogue" class. So, since I don't know what's going on with regards to
that class, I can't figure out what exactly is going wrong.

I don't know where you "have" this image button. If it is a member of the
"catalogue" class, what again does it have to do with an ASP.Net Page
class,
which you have talked about, but doesn't seem to appear anywhere in your
code?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
> Hello,
>
> I will try to describe my problem.
>
> In my page I have 2 distinct regions:
>
> 1. Datagrid which show a list of all products.
>
> 2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
> This will show the detailed information of a certain product.
>
> So when I choose a datagrid record the function Product_Detail is
> called
> and the Labels, Image and Image Buttons are filled with the right
> productid.
>
> I mentioned I have 3 ImageButtons in region 2 of the page. Why?
> These buttons show image thumbnails and when clicked call the function
> Zoom_Image which will show the right image in the ASP:Image.
>
> When Zoom_Image runs it needs to know which productid is current used
> in
> region 2. So everytime I click my datagrid I set the global variable
> currentproducti d=productid clicked.
>
> This way I when I press one of the image buttons the zoom function
> knows
> which record is in use.
>
> Does this make any sense?
>
> Somewhere here the global variable currentproducti d.
>
> Maybe my approach is wrong.
>
> Any idea?
>
> Thanks,
> Miguel
>
> "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
> news:ke***@DIES PAMMERSDIEtakem pis.com:
>

>> > I can see the e.CommandName value but not the productid.
>>
>>

>> Where can you see it?
>>
>> Also, you just might want to inherit System.Web.UI.P age in your class
>> if
>> you
>> expect any System.Web.UI.P age events (such as Page_Load) to fire.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Ambiguity has a certain quality to it.
>>
>> "Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
>> news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
>>

>> > Hello,
>> >
>> > I am declaring a variable in my aspx.vb code as follows:
>> >
>> > Public Class catalogue
>> > Public productid As String
>> > Private Sub Page_Load
>> > ...
>> >
>> > I have an image button where I call the following function:
>> >
>> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
>> > CommandEventArg s)
>> >
>> > Response.Write( productid)
>> > Response.Write( e.CommandName)
>> >
>> > End Sub
>> >
>> > I can see the e.CommandName value but not the productid.
>> >
>> > Is not productid global the way I declare it?
>> >
>> > Thanks,
>> > Miguel
>> >

>

Nov 19 '05 #8
Got lost. :-)

Well, I made this work using a Session Variable which holds the
productid value which is in use in the Detail Page.

The Session Value is reset only when Page_Load.

Does this allows to take any conclusion of what was happening when I was
using the global variable?

Cheers,
Miguel

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
Thanks Miguel,

I think it's getting a lot clearer.

I'm a little fuzzy on what the exact sequence of PostBacks and data changing
is. Something changes the value of CurrentProductI d, I think. But what
persists that value across PostBacks? Remember that a Page class lasts for
the time it takes to process a Request. Afterwards, the class is destroyed,
and rebuilt with the next Request. That is why ViewState exists, to restore
the values of Controls after a PostBack. But I can't tell for sure whether
the value is set during one PostBack and read in another, or how you are
persisting this value across PostBacks.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Yes, I have to admit my explanation was confusing.

1. All the functions are in Class Catalogue.
2. Yes, class catalogue is derived from Inherits System.Web.UI.P age.
The class is in catalogue.aspx. vb. It has the code for catalogue.aspx.

3. In my aspx page (HTML code) I have 2 div's:

A) DIV id="Products_Gr id"

DIV Products_Grid includes PRODUCTS datagrid which shows N records.

The DataGrid has 3 database fields:
1 - [Image01]
2 - [Title]
3 - [Price]

B) DIV id="Product_Det ail"

In DIV Product_Detail I have:
1 - One ASP:Image - [Image01] database field by default. Full Size.
2 - Three ASP:ImageButton s - 3 thumbnail images using the fields:
[Image01], [Image02], [Image03]
3 - Four ASP:Labels - [Title], [Description], [Price], [code]

4. My functions

A) Build_Grid()
Builds the PRODUCTS datagrid, binds it to data...

B) Change_Product( )
When a record in datagrid is pressed it changes all the ASP:Image,
ASP:ImageButton s and ASP:Labels in DIV Product_Detail.

Like a Master-Detail in the same page.

C) Change_Photo()
When an ASP:ImageButton is pressed it gets its value and change the
URL of full size image displayed in ASP:Image in DIV Product_Detail.

This is where I have the problem!

Change_Photo() receives the field to use from the ASP:ImageButton .
I am using e.CommandName.

Q: But what record is being displayed? What is its productid?
A: It is the same as last record pressed in the datagrid.
So my implementation is:

Change_Product( ) is called THEN:

Global variable CurrentProductI D = ProductID of row pressed in datagrid.
Change Product_Detail Labels and Images values using this record value.

Change_Photo() is called THEN
Get new Thumbnail to show in ASP:Image (full size) from e.CommmandName
Get CurrentProductI D
Change ASP:Image "Photo" using the 2 values.

Well, this might be confusing but it's nothing more then a master-detail
page in some page and in the detail part I have 3 thumbnails with a full
size feature for them.

Everything is working but when I click the image buttons it's like the
global variable CurrentProductI D is not available. I have no idea why.

Thanks,
Miguel






"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:

Hi Miguel,

I'm still confused. Sorry. First, what exactly do you mean by "region?"
In
Visual Studio.Net, a region is simply an organizational tool for use in
development, and has nothing to do with how an app works. In an ASP.Net
page, I have no idea what the word is supposed to represent.

Second, as I mentioned before, I saw some of your code, which defined a
class called "catalogue. " Here is a reproduction of the code you posted
initially:

> > Public Class catalogue
>> > Public productid As String
>> > Private Sub Page_Load
>> > ...

Now, the Page_Load Sub leads me to believe that this class is somehow
supposed to be derived from System.Web.UI.P age, but there is no
"Inherits"
statement that indicates that it does. So, part of my confusion extends
from
that.

After the ellipse, you state:

> > I have an image button where I call the following function:
>> >
>> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
>> > CommandEventArg s)

I'm not at all sure of what this class has to do with your Page, if
anything. The variable (field) "productid" is a public field of the
"catalogue" class. So, since I don't know what's going on with regards to
that class, I can't figure out what exactly is going wrong.

I don't know where you "have" this image button. If it is a member of the
"catalogue" class, what again does it have to do with an ASP.Net Page
class,
which you have talked about, but doesn't seem to appear anywhere in your
code?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Hello,
>
> I will try to describe my problem.
>
> In my page I have 2 distinct regions:
>
> 1. Datagrid which show a list of all products.
>
> 2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
> This will show the detailed information of a certain product.
>
> So when I choose a datagrid record the function Product_Detail is
> called
> and the Labels, Image and Image Buttons are filled with the right
> productid.
>
> I mentioned I have 3 ImageButtons in region 2 of the page. Why?
> These buttons show image thumbnails and when clicked call the function
> Zoom_Image which will show the right image in the ASP:Image.
>
> When Zoom_Image runs it needs to know which productid is current used
> in
> region 2. So everytime I click my datagrid I set the global variable
> currentproducti d=productid clicked.
>
> This way I when I press one of the image buttons the zoom function
> knows
> which record is in use.
>
> Does this make any sense?
>
> Somewhere here the global variable currentproducti d.
>
> Maybe my approach is wrong.
>
> Any idea?
>
> Thanks,
> Miguel
>
> "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
> news:ke***@DIES PAMMERSDIEtakem pis.com:
>
> > I can see the e.CommandName value but not the productid.
>>
>>
> Where can you see it?
>>
>> Also, you just might want to inherit System.Web.UI.P age in your class
>> if
>> you
>> expect any System.Web.UI.P age events (such as Page_Load) to fire.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Ambiguity has a certain quality to it.
>>
>> "Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
>> news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
>>
> > Hello,
>> >
>> > I am declaring a variable in my aspx.vb code as follows:
>> >
>> > Public Class catalogue
>> > Public productid As String
>> > Private Sub Page_Load
>> > ...
>> >
>> > I have an image button where I call the following function:
>> >
>> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
>> > CommandEventArg s)
>> >
>> > Response.Write( productid)
>> > Response.Write( e.CommandName)
>> >
>> > End Sub
>> >
>> > I can see the e.CommandName value but not the productid.
>> >
>> > Is not productid global the way I declare it?
>> >
>> > Thanks,
>> > Miguel
>> >

>



Nov 19 '05 #9
Looks like point 1 in my previous message.

In ASP.NET the page object is created each time there is an HTTP request. If
you give a value to a public variable in the first request, the value will
not be there during the next request (as this is a new page object) unless
you restored it...

Patrice

--

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> a écrit dans le message
de news:ez******** *****@TK2MSFTNG P12.phx.gbl...
Got lost. :-)

Well, I made this work using a Session Variable which holds the
productid value which is in use in the Detail Page.

The Session Value is reset only when Page_Load.

Does this allows to take any conclusion of what was happening when I was
using the global variable?

Cheers,
Miguel

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:
Thanks Miguel,

I think it's getting a lot clearer.

I'm a little fuzzy on what the exact sequence of PostBacks and data changing is. Something changes the value of CurrentProductI d, I think. But what
persists that value across PostBacks? Remember that a Page class lasts for the time it takes to process a Request. Afterwards, the class is destroyed, and rebuilt with the next Request. That is why ViewState exists, to restore the values of Controls after a PostBack. But I can't tell for sure whether the value is set during one PostBack and read in another, or how you are
persisting this value across PostBacks.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.

"Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Yes, I have to admit my explanation was confusing.

1. All the functions are in Class Catalogue.
2. Yes, class catalogue is derived from Inherits System.Web.UI.P age.
The class is in catalogue.aspx. vb. It has the code for catalogue.aspx.
3. In my aspx page (HTML code) I have 2 div's:

A) DIV id="Products_Gr id"

DIV Products_Grid includes PRODUCTS datagrid which shows N records.
The DataGrid has 3 database fields:
1 - [Image01]
2 - [Title]
3 - [Price]

B) DIV id="Product_Det ail"

In DIV Product_Detail I have:
1 - One ASP:Image - [Image01] database field by default. Full Size. 2 - Three ASP:ImageButton s - 3 thumbnail images using the fields:
[Image01], [Image02], [Image03]
3 - Four ASP:Labels - [Title], [Description], [Price], [code]

4. My functions

A) Build_Grid()
Builds the PRODUCTS datagrid, binds it to data...

B) Change_Product( )
When a record in datagrid is pressed it changes all the ASP:Image, ASP:ImageButton s and ASP:Labels in DIV Product_Detail.

Like a Master-Detail in the same page.

C) Change_Photo()
When an ASP:ImageButton is pressed it gets its value and change the URL of full size image displayed in ASP:Image in DIV Product_Detail.
This is where I have the problem!

Change_Photo() receives the field to use from the ASP:ImageButton . I am using e.CommandName.

Q: But what record is being displayed? What is its productid?
A: It is the same as last record pressed in the datagrid.
So my implementation is:

> Change_Product( ) is called THEN:

Global variable CurrentProductI D = ProductID of row pressed in datagrid. Change Product_Detail Labels and Images values using this record value.

> Change_Photo() is called THEN

Get new Thumbnail to show in ASP:Image (full size) from e.CommmandName Get CurrentProductI D
Change ASP:Image "Photo" using the 2 values.

Well, this might be confusing but it's nothing more then a master-detail page in some page and in the detail part I have 3 thumbnails with a full size feature for them.

Everything is working but when I click the image buttons it's like the
global variable CurrentProductI D is not available. I have no idea why.

Thanks,
Miguel






"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ke***@DIES PAMMERSDIEtakem pis.com:

> Hi Miguel,
>
> I'm still confused. Sorry. First, what exactly do you mean by "region?"> In
> Visual Studio.Net, a region is simply an organizational tool for use in> development, and has nothing to do with how an app works. In an ASP.Net> page, I have no idea what the word is supposed to represent.
>
> Second, as I mentioned before, I saw some of your code, which defined a> class called "catalogue. " Here is a reproduction of the code you posted> initially:
>
>

> >> > Public Class catalogue
> >> > Public productid As String
> >> > Private Sub Page_Load
> >> > ...
>
>

> Now, the Page_Load Sub leads me to believe that this class is somehow
> supposed to be derived from System.Web.UI.P age, but there is no
> "Inherits"
> statement that indicates that it does. So, part of my confusion extends> from
> that.
>
> After the ellipse, you state:
>
>

> >> > I have an image button where I call the following function:
> >> >
> >> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> >> > CommandEventArg s)
>
>

> I'm not at all sure of what this class has to do with your Page, if
> anything. The variable (field) "productid" is a public field of the
> "catalogue" class. So, since I don't know what's going on with regards to> that class, I can't figure out what exactly is going wrong.
>
> I don't know where you "have" this image button. If it is a member of the> "catalogue" class, what again does it have to do with an ASP.Net Page
> class,
> which you have talked about, but doesn't seem to appear anywhere in your> code?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Ambiguity has a certain quality to it.
>
> "Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
> news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
>

> > Hello,
> >
> > I will try to describe my problem.
> >
> > In my page I have 2 distinct regions:
> >
> > 1. Datagrid which show a list of all products.
> >
> > 2. Region with 4 ASP Labels, 1 ASP Image and 3 ASP Image Buttons.
> > This will show the detailed information of a certain product.
> >
> > So when I choose a datagrid record the function Product_Detail is
> > called
> > and the Labels, Image and Image Buttons are filled with the right
> > productid.
> >
> > I mentioned I have 3 ImageButtons in region 2 of the page. Why?
> > These buttons show image thumbnails and when clicked call the function> > Zoom_Image which will show the right image in the ASP:Image.
> >
> > When Zoom_Image runs it needs to know which productid is current used> > in
> > region 2. So everytime I click my datagrid I set the global variable> > currentproducti d=productid clicked.
> >
> > This way I when I press one of the image buttons the zoom function
> > knows
> > which record is in use.
> >
> > Does this make any sense?
> >
> > Somewhere here the global variable currentproducti d.
> >
> > Maybe my approach is wrong.
> >
> > Any idea?
> >
> > Thanks,
> > Miguel
> >
> > "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
> > news:ke***@DIES PAMMERSDIEtakem pis.com:
> >
>

> >> > I can see the e.CommandName value but not the productid.
> >>
> >>
>

> >> Where can you see it?
> >>
> >> Also, you just might want to inherit System.Web.UI.P age in your class> >> if
> >> you
> >> expect any System.Web.UI.P age events (such as Page_Load) to fire.
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> .Net Developer
> >> Ambiguity has a certain quality to it.
> >>
> >> "Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message> >> news:Ov******** *****@TK2MSFTNG P15.phx.gbl...
> >>
>

> >> > Hello,
> >> >
> >> > I am declaring a variable in my aspx.vb code as follows:
> >> >
> >> > Public Class catalogue
> >> > Public productid As String
> >> > Private Sub Page_Load
> >> > ...
> >> >
> >> > I have an image button where I call the following function:
> >> >
> >> > Public Sub MyFunction(ByVa l sender As Object, ByVal e As
> >> > CommandEventArg s)
> >> >
> >> > Response.Write( productid)
> >> > Response.Write( e.CommandName)
> >> >
> >> > End Sub
> >> >
> >> > I can see the e.CommandName value but not the productid.
> >> >
> >> > Is not productid global the way I declare it?
> >> >
> >> > Thanks,
> >> > Miguel
> >> >
>
> >


Nov 19 '05 #10

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

Similar topics

8
102747
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions> <instructions> def bar: <instructions>
4
24171
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); function loadUrlVariables() { varString = location.search;
4
7106
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
2
8816
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book { public: Book()
8
2530
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined in global space, therefore it is not a global variable, yes? Even if it was global, how would it get from one function to another? In PHP variables are copied by value. Are they copied by reference in Javascript? <SCRIPT LANGUAGE="JavaScript">
17
5612
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
10
2643
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of the more specialist aspects of the job but am now completely stuck on something I would have thought were simplicity itself... I need to have a large number of global variables visible inside functions - it's not possible to pass them into the...
9
3018
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
29337
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
112
5415
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
8221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8603
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6104
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2593
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1468
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.