Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        URLPathUtility upu = new URLPathUtility();

        System.Text.StringBuilder builder = new System.Text.StringBuilder();
        foreach (string s in System.Web.HttpContext.Current.Request.ServerVariables.AllKeys)
        {
            builder.Append(s);
            builder.Append(" = ");
            builder.Append(System.Web.HttpContext.Current.Request.ServerVariables[s]);
            builder.Append("<br />");
        }
        builder.Append(System.Web.HttpContext.Current.Request.Path);
        builder.Append("<br />");
        builder.Append(System.Web.HttpContext.Current.Request.ApplicationPath);
        builder.Append("<br />");
        builder.Append(System.Web.HttpContext.Current.Server);
        builder.Append("<br />");
        builder.Append(System.Web.HttpContext.Current.Request.UserHostName);
        builder.Append("<br /><br /><br />");
        builder.Append(VirtualPathUtility.ToAbsolute(Request.ApplicationPath));
        builder.Append("<br />");
        builder.Append(VirtualPathUtility.ToAppRelative(Request.ApplicationPath));
        builder.Append("<br /><br /><br />");
        builder.Append(upu.GetNavigableAppPath());
        Literal1.Text = builder.ToString();
    }
Exemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        BlogPost bPost = new BlogPost();

        bPost.Title = TextBox1.Text;
        System.Text.StringBuilder builder = new StringBuilder();
        builder.Append("<![CDATA[");
        builder.Append(FreeTextBox1.Text);
        builder.Append("]]>");
        bPost.Text    = builder.ToString();
        bPost.Created = DateTime.Now.ToString();
        if (!String.IsNullOrEmpty(Request.QueryString["postID"]))
        {
            bPost.ID = (string)Request.QueryString["postID"];
        }
        if ((!String.IsNullOrEmpty(Page.User.Identity.Name)))
        {
            bPost.CreatedBy = (string)Page.User.Identity.Name;
        }
        else
        {
            bPost.CreatedBy = "Unknown";
        }
        PostBroker broker = new PostBroker();

        broker.InsertPost(bPost);
        URLPathUtility upu = new URLPathUtility();

        Response.Redirect(upu.GetNavigableAppPath() + "Default.aspx");
    }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(Request.QueryString["postID"]))
     {
         URLPathUtility upu    = new URLPathUtility();
         string         postID = Request.QueryString["postId"].Replace(".xml", String.Empty);
         PostBroker     broker = new PostBroker();
         broker.DeletePostByID(postID);
         Response.Redirect(upu.GetNavigableAppPath() + "Default.aspx");
     }
 }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Configuration.AppSettingsReader reader = new AppSettingsReader();
        downloadDir = (string)reader.GetValue("downloadPath", downloadDir.GetType());
        string        downloadPath = Server.MapPath(downloadDir);
        StringBuilder litBuilder   = new StringBuilder();
        DirectoryInfo dir          = new DirectoryInfo(downloadPath);

        FileInfo[]     filesInDir = dir.GetFiles("*.*");
        URLPathUtility upu        = new URLPathUtility();

        litBuilder.Append("<table width=\"99%\" border=\"0\" cellpadding=\"2\">");
        int itemCount = 0;
        int totFiles  = GetFileNames(downloadPath).Count;

        foreach (FileInfo f in filesInDir)
        {
            if (itemCount == 0)
            {
                litBuilder.Append("<tr>");
            }
            litBuilder.Append("<td width=\"20%\" align=\"center\" valign=\"top\">");
            litBuilder.Append("<br />");
            litBuilder.Append("<a href=\"");
            litBuilder.Append(upu.GetNavigableAppPath() + "protected/" + downloadDir + "/");
            litBuilder.Append(f.Name);
            litBuilder.Append("\">");
            litBuilder.Append("<img src=\"");
            litBuilder.Append(upu.GetNavigableAppPath() + GetImageForExtension(f.Extension));
            litBuilder.Append("\"/>");
            litBuilder.Append("<br />");
            litBuilder.Append(f.Name);
            litBuilder.Append("</a>");
            litBuilder.Append("<br />");
            litBuilder.Append("</td>");
            itemCount++;
            if (itemCount >= 4)
            {
                litBuilder.Append("</tr>");
                itemCount = 0;
            }
        }
        if (itemCount > 0)
        {
            litBuilder.Append("</tr>");
        }
        litBuilder.Append("</table>");
        Literal1.Text = litBuilder.ToString();
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        URLPathUtility upu = new URLPathUtility();

        System.Text.StringBuilder builder = new System.Text.StringBuilder();
        PostBroker pb = new PostBroker();

        System.Collections.Generic.List <BlogPost> bpCol = new System.Collections.Generic.List <BlogPost>();

        if (!string.IsNullOrEmpty(Request.QueryString["RequestedDate"]))
        {
            bpCol = pb.GetPostsForDay(DateTime.Parse(Request.QueryString["RequestedDate"]));
        }
        else
        {
            bpCol = pb.GetMainPagePosts();
        }

        foreach (BlogPost post in bpCol)
        {
            builder.Append("<h1>").Append(post.Title).Append("</h1>");
            builder.Append("<p>");
            builder.Append(Server.HtmlDecode(post.Text));
            builder.Append("</p>");
            builder.Append("<p>Posted by ");
            builder.Append(post.CreatedBy.ToString());
            builder.Append(" on ");
            builder.Append(DateTime.Parse(post.Created).ToString());
            builder.Append("</p>");

            if (!String.IsNullOrEmpty(Page.User.Identity.Name) && post.CreatedBy == Page.User.Identity.Name)
            {
                builder.Append("<p><a href=\"");
                builder.Append(upu.GetNavigableAppPath());
                builder.Append("protected/CreatePost.aspx?postID=");
                builder.Append(post.ID.Replace(".xml", String.Empty));
                builder.Append("\"><img src=\"images/edit.gif\"/> Edit</a>");
                builder.Append("&nbsp&nbsp");
                builder.Append("<a href=\"");
                builder.Append(upu.GetNavigableAppPath());
                builder.Append("protected/DeletePost.aspx?postID=");
                builder.Append(post.ID.Replace(".xml", String.Empty));
                builder.Append("\"><img src=\"images/trash.gif\"/> Delete</a></p>");
            }
            Literal1.Text = builder.ToString();
        }
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        URLPathUtility upu = new URLPathUtility();

        System.Text.StringBuilder builder = new System.Text.StringBuilder();
        PostBroker pb = new PostBroker();

        builder.Append("<p>");
        foreach (string dt in pb.GetAllDaysWithPosts())
        {
            builder.Append("<a href=\"" + upu.GetNavigableAppPath() + "Default.aspx?RequestedDate=");
            builder.Append(dt);
            builder.Append("\">");
            builder.Append(DateTime.Parse(dt).ToLongDateString());
            builder.Append("</a>");
            builder.Append("<br />");
        }
        builder.Append("</p>");
        Literal1.Text = builder.ToString();
    }