[ VLSE @ 17.07.2007. 20:35 ] @
Ja sam malo poceo da se bavim ASP.NET-om pa mi je zapelo.Ko ume da mi kaze zasto ovo ne radi neka pomogne. Evo je xml-datoteka: <?xml version="1.0"?> <Entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Title>Hello!</Title> <Details>These are the details of the Weblog entry</Details> </Entry> Evo ga kod koji bi trebao da je koristi,bar po knjizi ali nece bato ili seko: Kod za Default.aspx je : namespace Weblog1 { /// <summary> /// Summary description for _Default. /// </summary> public class _Default : System.Web.UI.Page { protected System.Web.UI.WebControls.Label labelServerPath; protected System.Web.UI.WebControls.Label labeEntryTitle; protected System.Web.UI.WebControls.Label labelEntryDetails; protected System.Web.UI.WebControls.Label labelCopyright; private void Page_Load(object sender, System.EventArgs e) { //koja je godina? int year=DateTime.Now.Year; if(year==2001) labelCopyright.Text="Copyright &cpoy; Disraeli" + year; else labelCopyright.Text="Copyright © Disrael 2001-" + year; //postavljamo putanju servera labelServerPath.Text=Global.EntryFilePath; //ucitavamo unos sa diska... Entry entry=Global.LoadEntry("Entry.xml"); labelEntryTitle.Text=entry.Title; labelEntryDetails.Text=entry.Details; Kod za Global asa.x je : using System; using System.Collections; using System.ComponentModel; using System.Web; using System.Web.SessionState; using System.IO; using System.Xml.Serialization; namespace Weblog1 { /// <summary> /// Summary description for Global. /// </summary> public class Global : System.Web.HttpApplication { public static String EntryFilePath; //Ucitava unos sa diska public static Entry LoadEntry(String filename) { //imamo ime,ali nam treba i putanja... String filepath=EntryFilePath + "\\" + filename; //otvaramo datoteku... FileStream file=new FileStream(filepath,FileMode.Open); //kreiramo objekat za serijalizaciju... XmlSerializer serializer=new XmlSerializer(typeof(Entry)); Entry newEntry= (Entry)serializer.Deserialize(file); //zatvramo datoteku... file.Close(); //vracamo unos... return newEntry; } private System.ComponentModel.IContainer components = null; public Global() { InitializeComponent(); } protected void Application_Start(Object sender, EventArgs e) { EntryFilePath=Server.MapPath("Entries"); } protected void Session_Start(Object sender, EventArgs e) { } protected void Application_BeginRequest(Object sender, EventArgs e) { } protected void Application_EndRequest(Object sender, EventArgs e) { } protected void Application_AuthenticateRequest(Object sender, EventArgs e) { } protected void Application_Error(Object sender, EventArgs e) { } protected void Session_End(Object sender, EventArgs e) { } protected void Application_End(Object sender, EventArgs e) { } Evo je i Klasa Entry.cs: using System; using System.IO; using System.Xml.Serialization; namespace Weblog1 { /// <summary> /// Summary description for Entry. /// </summary> public class Entry { private DateTime_timestamp; private String_title; private String_details; [XmlIgnore()] public DateTime Timestamp { get { return_timestamp; } set { _timestamp=value; } } public String Title { get { return_title; } set { _title=value; } } public String Details { get { return_details; } set { _details=value; } } public Entry() { // // TODO: Add constructor logic here // } A ovo mi izbacuje kao gresku: c:\inetpub\wwwroot\Weblog1\Entry.cs(13): Invalid token ';' in class, struct, or interface member declaration c:\inetpub\wwwroot\Weblog1\Entry.cs(14): Invalid token ';' in class, struct, or interface member declaration c:\inetpub\wwwroot\Weblog1\Entry.cs(12): Invalid token ';' in class, struct, or interface member declaration A ovo mi izbacuje u Explorer-u,kad pokrenem projekat: Disrael's Weblog entryTitle entryDetails Copyright © Disrael 2001-2007 c:\inetpub\wwwroot\Weblog1 Normalno u Dizajneru sam sve povezao kako je u knjizi. E sad pomagajte posto je za iskusnog programera ovo igracka. Jos nesto,ja sam instalirao SQL-server,moze li mi neko reci kako da ga povesem sa mojim sajtom.Mislim ne bih sad da ucim da Pravim baze u SQL-u,vec me samo interesije ima li neko neku knjigu na ovu temu,ali za pocetnike.Kako da iskopristim mogucnosti SQL-a za potrebe pravljenja sajta,moze i na Engleskom. |