Validation of value in XML File

MyDoom

New Member
I'm trying to validate a username check box to see if the value entered exists in an XML file.On button click, it should check if the name entered exists within the XML file and then proceed, if not the message box should appear.The current code shows that the txt_Username.Text = Pupil.forename is inaccessible due to its protection level.On button click:\[code\]private void btnNext_Click(object sender, RoutedEventArgs e, Pupil p){ if (txt_Username.Text = Pupil.forename) { this.Hide(); Display nw = new Display(theClass); nw.ShowDialog(); this.Show(); } MessageBox.Show("Cannot Find username");}\[/code\]Pupil Class:\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace PassingData{ public class Pupil { private string forename; private int score; public Pupil(string forename, int score) { this.forename = forename; this.score = score; } public Pupil() { this.forename = "Unknown"; } public string Forename { get { return forename; } set { forename = value; } } public int Score { get { return score; } set { score = value; } } override public string ToString() { string output = forename + "\t" + score; return output; } }}\[/code\]XML File:\[code\]<?xml version="1.0" encoding="utf-8"?><ArrayOfPupil xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Pupil> <Forename>Andy</Forename> <Score>0</Score> </Pupil> <Pupil> <Forename>Bob</Forename> <Score>10</Score> </Pupil> <Pupil> <Forename>Carl</Forename> <Score>20</Score> </Pupil> <Pupil> <Forename>Dave</Forename> <Score>30</Score> </Pupil> <Pupil> <Forename>Eric</Forename> <Score>40</Score> </Pupil> <Pupil> <Forename>Frank</Forename> <Score>50</Score> </Pupil></ArrayOfPupil>\[/code\]
 
Back
Top