using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; //using System.Web.HttpContext; using System.Text.RegularExpressions; public partial class novosti : System.Web.UI.Page { string connStr = ConfigurationManager.ConnectionStrings["Localhost"].ConnectionString; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ucitajNovost(); } } // // protected void ucitajNovost() { int novostId; string datum = null; string slika = null; string naslov = null; string tekst = null; // novostId = Convert.ToInt32(Request["novostId"]); // OleDbConnection aConnection = new OleDbConnection(connStr); OleDbCommand aCommand = new OleDbCommand("SELECT * FROM HA_UcitajNovosti WHERE NovostId=" + novostId, aConnection); aConnection.Open(); OleDbDataReader aReader = aCommand.ExecuteReader(); while (aReader.Read()) { // datum = aReader["Datum"].ToString(); slika = aReader["Slika"].ToString(); naslov += Server.UrlDecode(aReader["Naslov"].ToString()); tekst = Server.UrlDecode(aReader["Tekst"].ToString()); // } // // aConnection.Close(); // Naslov.Text = naslov; Datum.Text = formatDatum(datum); Slika.ImageUrl = formatSliku(slika); Tekst.Text = tekst; // //Response.Write(Request.Path.ToString()); // //rewriteURL(); } private string formatDatum(string datum) { string datumFormat = null; // datumFormat = datum.Remove(datum.Length - 8, 8); // return datumFormat; } private string formatSliku(string slika) { string imagePath = null; imagePath = slika.Insert(15, "velike/"); return imagePath; } private void rewriteURL() { HttpContext myContext = HttpContext.Current; Regex rewrite_regex = new Regex(@"(.+)\/((.+)\.aspx)", RegexOptions.IgnoreCase); //see if we need to rewrite the URL Match match_rewrite = rewrite_regex.Match(myContext.Request.Path.ToString()); Response.Write(match_rewrite.Groups[2].Captures[0].ToString()); if (match_rewrite.Groups[2].Captures[0].ToString() == "novosti.aspx") { // myContext.RewritePath("default.aspx", true); } } }