using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class main_test : System.Web.UI.Page {

    private NorthwindDataContext db = new NorthwindDataContext();
    private Table<test> ttesty = null;

    protected void Page_Init(object sender, EventArgs e) {
        //adding CSS style file
        HtmlLink newCSS = new HtmlLink();
        newCSS.Href = "~/css/testy_style.css";
        newCSS.Attributes.Add("type", "text/css");
        newCSS.Attributes.Add("rel", "Stylesheet");
        Page.Header.Controls.Add(newCSS);
        //create tables
        this.ttesty = db.GetTable<test>();
    }

    protected void Page_Load(object sender, EventArgs e) {
        // id zobrazovaneho clanku
        string req_param = Request.QueryString["id"];
        try {
            int req_id = Int16.Parse(req_param);
            test test = ttesty.Single(c => c.test_id == req_id);
            title.Text = test.title;
        }
        catch (InvalidOperationException ex) {
            //zapis log
            Response.Redirect(@"~/main/clanky.aspx");
        }
        catch (ArgumentNullException ex) {
            //zapis log
            Response.Redirect(@"~/main/clanky.aspx");
        }
        catch (Exception ex) {
            //zapis log
            Response.Redirect(@"~/main/clanky.aspx");
        }

    }
}
