Advertisement
futog

Default.aspx drugi zadatak

Mar 5th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 1.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.IO;
  8.  
  9. namespace WebApplication4
  10. {
  11.     public partial class _Default : System.Web.UI.Page
  12.     {
  13.         private ocena o = new ocena();
  14.         protected void Page_Load(object sender, EventArgs e)
  15.         {
  16.             if (DropDownList1.Items.Count == 0)
  17.             {
  18.                 List<string> lista = napuniListu();
  19.  
  20.                 DropDownList1.Items.Clear();
  21.                 foreach (string line in lista)
  22.                 {
  23.                     DropDownList1.Items.Add(line);
  24.                 }
  25.             }
  26.         }
  27.  
  28.         private List<string> napuniListu()
  29.         {
  30.             List<string> lista = new List<string>();          
  31.             try
  32.             {
  33.                 StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("~/Ucenici.txt"));
  34.                 string line = sr.ReadLine();
  35.                 string[] a;
  36.                 while (!string.IsNullOrEmpty(line))
  37.                 {
  38.                     a = line.Split('|');
  39.                     line = a[0] + " " + a[1];
  40.                     lista.Add(line);
  41.                     line = sr.ReadLine();
  42.                 }
  43.             }
  44.             catch (Exception e)
  45.             {
  46.                 Console.WriteLine(e);
  47.             }
  48.             return lista;
  49.         }
  50.  
  51.         protected void Button1_Click1(object sender, EventArgs e)
  52.         {
  53.             string line = DropDownList1.SelectedItem.Text;
  54.             string[] info = line.Split(' ');
  55.             Label1.Text = "Prosecna ocena: " + o.ucitajOcenu(info[0], info[1]);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement