Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session variables

Status
Not open for further replies.

MikeMCSD

MIS
Jul 12, 2002
107
US
How would update a Label on a User Control (.ascx.vb file) with a Session variable from another User Control as that variable is changed?

I want to update the shopping cart total at the top of the page (a Header as a User Control) when
"Add to Cart" is clicked from another control:

Session("total") = String.Format("{0:c}", cart.amt)

Then I want the Label in the other control (Header) updated
as soon as it is changed from the other control:

total.Text = Session("total")

Can this be done?
Thanks
 
to make the update real-time you need a post back to the server or a bit of JavaScript. depending whether you want another round trupt to the server or not for each update you will use one sollution or the other

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
if you decide upon posting the data back to the server, you should do fine with what you wrote in your post.

if you need to use this on client side, you would need to use something like
document.getElementById("total").value = document.getElementById("cart").value;

assuming that the id of total is total and that of cart is cart

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top