?
Solved

ASP.NET Adding Numbers

Posted on 2006-05-04
1
Medium Priority
?
244 Views
Last Modified: 2008-03-17
hi,

real quick one. I have made this quick script that simply adds one to a public integer. I then write it to screen. This is triggered by clicking a Linkbutton.

I think the code is fine but it is not adding one to the value, or it is not displaying the most recehnt value

Thanks in advance

Andrew

    protected void HyperLink1_Click(object sender, EventArgs e)
    {
        MyValue += 1;
        Response.Write(MyValue);
    }
0
Comment
Question by:REA_ANDREW
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 16606219
How have you declared MyValue ? If it is simply a public field in your page then it will not retain its value between posts. You would need to store the value in the session, or the viewstate, or somewhere else with a more persistent scope.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question