Okay, this is the first time posting here. I'm converting a c# program to asp.net for web deployment. My problem is, and for the love of god I can't find an answer any where. My labels, when I run it locally on chrome using visual studio, update. But when I move it to the remote server on Azure, the labels do not get updated. I have the free account so it's hard to do any debugging remotely. Everything else works, just not this. It not only is frustrating, but I have tried most of the solutions I have seen on this site and others for problems slightly similar but nothing is working.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BoggleBoardWeb
{
public partial class BoggleBoard : Page
{
static int width_ = 4;
static int desiredLength_ = 3;
static int desiredSeed_ = 7;
static int divisorHeight = 0;
static int divisorWidth = 0;
static int scoreComp;
static int scoreHuman;
static Queue<Tuple<string, char>> stringValues = new Queue<Tuple<string, char>>();
static BogglePieceGenerator generator = new BogglePieceGenerator(width_, desiredSeed_);
static BoggleBoard_Board boardInformation = new BoggleBoard_Board(width_, generator);
static List<string> acceptedWords = new List<string>();
static private char[,] board2D = new char[width_, width_];
static Lexicon lexi = new Lexicon("lexicon-clean.txt");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillBoard();
computerScoreDisplay.Text = scoreComp.ToString();
humanScoreDisplay.Text = scoreHuman.ToString();
}
while (this.Panel1.Height.Value % width_ != 0)
{
this.Panel1.Height = new Unit(this.Panel1.Height.Value - 1);
}
divisorHeight = (int)this.Panel1.Height.Value / width_;
divisorHeight -= 2;
while (this.Panel1.Width.Value % width_ != 0)
{
this.Panel1.Width = new Unit(this.Panel1.Width.Value - 1);
}
divisorWidth = (int)this.Panel1.Width.Value / width_;
divisorWidth -= 2;
gridLayout();
computerScoreDisplay.Text = scoreComp.ToString();
humanScoreDisplay.Text = scoreHuman.ToString();
}
private char[,] fillBoard()
{
for (int x = 0; x < width_; x++)
{
for (int y = 0; y < width_; y++)
{
board2D[x, y] = boardInformation.getLetter(x, y);
}
}
return board2D;
}
public BoggleBoard()
{
}
public void gridLayout()
{
Button[,] grid = new Button [width_,width_];
for(int height = 0; height < width_; height++)
{
for(int width = 0; width < width_; width++)
{
grid[width, height] = new Button();
grid[width, height].Text = board2D[width,height].ToString();
grid[width, height].ID = width.ToString() + '_' + height.ToString() + '_' + "btn";
grid[width, height].Width = divisorWidth;
grid[width, height].Height = divisorHeight;
grid[width, height].BackColor = System.Drawing.Color.White;
grid[width, height].Visible = true;
grid[width, height].Click += new System.EventHandler(OnClick);
this.Panel1.Controls.Add(grid[width, height]);
}
}
}
protected void OnClick(object sender, EventArgs e)
{
Button temp = sender as Button;
if( temp.BackColor == System.Drawing.Color.White)
{
temp.BackColor = System.Drawing.Color.Red;
stringValues.Enqueue(new Tuple<string, char>(temp.ID, temp.Text.ToCharArray()[0]));
}
else
{
Button button;
for (int height = 0; height < width_; height++)
{
for (int width = 0; width < width_; width++)
{
string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
button = (Button)this.Panel1.FindControl(locator.ToString());
button.BackColor = System.Drawing.Color.White;
}
}
stringValues.Clear();
}
}
protected void Check_Click(object sender, EventArgs e)
{
Panel playArea = (Panel)FindControl("Panel1");
if (stringValues.Count != 0)
{
string stringToBeSent = new string(stringValues.Dequeue().Item2, 1);
while (stringValues.Count != 0)
{
stringToBeSent += stringValues.Dequeue().Item2;
}
if (stringToBeSent.Length >= desiredLength_ && !hasBeenPlayer(stringToBeSent) && lexi.wordStatus(stringToBeSent) == Lexicon.Status.WORD)
{
if (boardInformation.isWordOnBoard(stringToBeSent))
{
acceptedWords.Add(stringToBeSent);
this.humanScoreDisplay.Text = acceptedWords.Count.ToString();
scoreHuman = acceptedWords.Count;
}
}
Button button;
for (int height = 0; height < width_; height++)
{
for (int width = 0; width < width_; width++)
{
string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
button = (Button)this.Panel1.FindControl(locator.ToString());
button.BackColor = System.Drawing.Color.White;
}
}
}
}
private bool hasBeenPlayer(string wordToBeCheck)
{
foreach(string word in acceptedWords)
{
if(word == wordToBeCheck)
{
return true;
}
}
return false;
}
protected void doneBTN_Click(object sender, EventArgs e)
{
ComputerPlayer compPlayer = new ComputerPlayer(lexi);
List<string> computerPlayedWords = compPlayer.playBoggle(boardInformation, acceptedWords, 3);
this.computerScoreDisplay.Text = computerPlayedWords.Count.ToString();
scoreComp = computerPlayedWords.Count;
finishBTN.Visible = true;
}
protected void playAgain_Click(object sender, EventArgs e)
{
boardInformation = new BoggleBoard_Board(width_, generator);
board2D = new char[width_, width_];
board2D = fillBoard();
Button button;
for (int height = 0; height < width_; height++)
{
for (int width = 0; width < width_; width++)
{
string locator = width.ToString() + '_' + height.ToString() + '_' + "btn";
button = (Button)this.Panel1.FindControl(locator.ToString());
this.Panel1.Controls.Remove(button);
}
}
gridLayout();
scoreComp = 0;
scoreHuman = 0;
}
}
}
here is the code behind for the program. I have add the label more often then I originally did to see if maybe it was an event issue, it is not. still works locally not remotely.
here is the front end code:
<%@ Page Title= "BoogleBoard" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="BoggleBoard.aspx.cs" Inherits="BoggleBoardWeb.BoggleBoard" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="840px" Width="840px" BorderStyle="Groove" ToolTip="Click the bottoms to move" ViewStateMode="Enabled">
</asp:Panel>
<asp:Button ID="checkBTN" runat="server" Text="Check Word" OnClick="Check_Click" Visible="True" Width="145px" />
<asp:Button ID="finishBTN" runat="server" Text="Finish" OnClick="doneBTN_Click" Visible="True" Width="116px" />
<asp:Button ID="playAgain" runat="server" Text="Play Again" OnClick="playAgain_Click" Visible="True" Width="92px" />
<p><asp:Label ID="humanScore" runat="server" Text="Your Score: "></asp:Label>
<asp:Label ID="humanScoreDisplay" runat="server" Text="0" BorderStyle="Groove" CssClass="active" AssociatedControlID="checkBTN"></asp:Label></p>
<p><asp:Label ID="ComputerScoreLabel" runat="server" Text="Computer Score: "></asp:Label>
<asp:Label ID="computerScoreDisplay" runat="server" Text="0" BorderStyle="Groove" CssClass="active" AssociatedControlID="finishBTN"></asp:Label>
</p>
</asp:Content>
If some of this seems rough, I apologize, like I said I'm learning asp.net to help myself in the job market. I don't normally ask for help, but I'm lost on why this is doing this, or not in this case. Any suggestions, help, or feedback/information will be greatly appreciated. Like I said this works perfectly on my local machine using visual studio, just not on azure. I do not have any other server to try this on.
Thank you,
Lee