It's been a long while since I've last been here but I've spent the last 2 hours pulling my hair out trying to figure this out and I'm hoping for a bit of help with this one.
I have a question/response check (a human verification check) on my page and it refuses to work... I've written the code such that it generates the question and answer on Page_Load only on the first (non postback) load. I've generated a label which has it's text property pulled from the Question as generated on Page_Load and I'm trying to validate the answer from the generated answer from Page_Load. For some reason it always validates as false even if I put the answer straight from the expected answer into the text box I'm validating from.
Question/Answer Generation:
private string hQuest;
private string hAns;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == false)
{
humQChange();
}
}
private void humQChange()
{
humScript regHum = new humScript();
hQuest = regHum.getHQuestion();
hAns = regHum.getHAnswer();
hQuestionLabel.Text = hQuest;
}
Validation:
private bool checkHumResp()
{
if (hAnswer.Text == hAns)
{
return true;
}
else
{
testLabel.Text = "Failed";
return false;
}
}
Even if I put a line of code in that tells it to fill hAnswer.Text with the value from hAns I still get a failure when validating one against the other. Both are string based variables so this isn't making any kind of sense to me.
Any suggestions?