2
Answers

Where Can I Put Logic in Code-Behind ASP.NET

Pal

Pal

16y
2.7k
1

Hi! I have two Textboxes(tbto and tbdate) and a Button(SearchButton). Following is code behind. This code works fine for value entered in Textbox(tbto) and I am stuck where I can put some logic for Textbox(tbdate), so it will take input from user and readfrom XML file and would show up result. In other words, user can put value in both text boxes and result would come up. Assuming date is in format 08/14/2008. I mean that is one of the value of tbdate.

protected void Show_Salaries(object Src, EventArgs Args)
    {
        XmlTextReader XMLReader = new XmlTextReader(MapPath("flightdb.xml"));
        XMLReader.MoveToContent();
 
        string Var_Airlinename = string.Empty;
        string Var_departloc = string.Empty;
        string Var_arrivalloc = string.Empty;
 
        while (XMLReader.Read())
        {
            if (XMLReader.Name == "Airline_Name" & XMLReader.NodeType == XmlNodeType.Element)
            {
                XMLReader.Read();
                Var_Airlinename = XMLReader.Value;   //Saving Airline name
                //SearchResult.Text += Var_Airlinename + "<br/>";
            }
           
            if (XMLReader.Name == "Depart_Loc" & XMLReader.NodeType == XmlNodeType.Element)
            {
                XMLReader.Read();
                Var_departloc = XMLReader.Value;   //Saving Departure location
            }
 
            if (XMLReader.Name == "Arrival_Loc" & XMLReader.NodeType == XmlNodeType.Element)
            {
                XMLReader.Read();
                if (XMLReader.Value == tbto.Text)
                {
                    Var_arrivalloc = XMLReader.Value;
                    SearchResult.Text += Var_Airlinename + " : " + Var_departloc + " - " +    Var_arrivalloc + "<br/>";
                }
            }
         }
 
        XMLReader.Close();
     }

Thanks for the answer.

Answers (2)