views:

104

answers:

1

I have a facebook game application that is released at facebook platform at the following link : FaceBookGameApplication

and i am using iframe and the problem now that after answering the question in the game i reload the page from javascript code :

window.location.href = sURL;

and on posting back i am updatting 2 divs of the score and hits with new values by getting the value exists and incrementing it with one according to user answer as the game is some questions and user answers them :

Hits = int.Parse(HitsNo.InnerText) + 1;
HitsNo.InnerText = Hits.ToString();

or :

Hits = int.Parse(HitsNo.InnerHTML) + 1;
HitsNo.InnerHTML = Hits.ToString();

and in the first time of reloading the values are changed and after that on each time of the reload the values don't change and the 2 divs don't take the new values that i set to them. The 2 divs runat server and i am using C# under .Net 2008 so what cause the two divs not changing thier innerText or innerHTML with new valuies io set from codebehind?

thanks in advance

+1  A: 

If I'm following correctly, you're using HTML divs to display the score. Then from code-behind, you're retrieving the HTML from those divs to access the most recent score value.

The problem then is that the DIVs are not part of the http post. Therefore each time your code-behind runs it is using the original value, adding one to it, and then displaying the new value. The next time the postback occurs, again it uses the original value, adds one, and displays.

Instead, use a hidden input element to store the score, as that will be part of the http post each round trip.

For example:

<input type="hidden" id="HitsNo" value="1" runat="server" />

Then you can access that hidden value in your code-behind.

Ken Pespisa