-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnglishStudyMaterialsTeacher.aspx.cs
More file actions
83 lines (69 loc) · 2.96 KB
/
Copy pathEnglishStudyMaterialsTeacher.aspx.cs
File metadata and controls
83 lines (69 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Drawing;
namespace teachingPlatform
{
public partial class EnglishStudyMaterialsTeacher : System.Web.UI.Page
{
private string serverPath;
private string filePath = "Data/resources/english/";
protected void Page_Load(object sender, EventArgs e)
{
serverPath = Server.MapPath(filePath);
Panel1.Controls.Clear();
Panel1.Controls.Add(new LiteralControl("<br/>"));
string[] files = Directory.GetFiles(serverPath);
if (files.Length == 0)
{
Label label = new Label();
label.Text = "No materials uploaded";
label.ForeColor = Color.FromArgb(247, 248, 255);
Panel1.Controls.Add(label);
}
foreach (String file in files)
{
Panel newPanel = new Panel();
//newPanel.BorderStyle = BorderStyle.Solid;
//newPanel.BorderColor = Color.FromArgb(68, 126, 248);
//newPanel.Width = Unit.Percentage(50);
HyperLink hyperlink = new HyperLink();
hyperlink.NavigateUrl = filePath + Path.GetFileName(file);
hyperlink.Text = Path.GetFileName(file);
hyperlink.Target = "_blank";
//hyperlink.ForeColor = Color.FromArgb(0, 97, 216);
hyperlink.ForeColor = Color.FromArgb(247, 248, 255);
newPanel.Controls.Add(hyperlink);
Panel1.Controls.Add(newPanel);
Panel1.Controls.Add(new LiteralControl("<br/>"));
}
Site1 master = (Site1)this.Master;
master.StudyMaterials.NavigateUrl = "EnglishStudyMaterialsTeacher.aspx";
master.PracticeTests.NavigateUrl = "EnglishPracticeTestsTeacher.aspx";
master.HomePage.NavigateUrl = "TeacherHomepage.aspx";
master.DiscussionForum.NavigateUrl = "ENdiscussionForum.aspx";
}
protected void UploadButton_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
if (extension == ".pdf")
{
//FileUpload1.PostedFile.SaveAs(Path.Combine(filePath, FileUpload1.FileName));
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/" + filePath) + FileUpload1.FileName);//Server.MapPath("~") + "/App_Data/resources/english/" + FileUpload1.FileName);
Label1.Text = FileUpload1.FileName + " uploaded.";
this.Page_Load(sender, e);
}
else
Label1.Text = "Only PDFs allowed.";
}
else
Label1.Text = "No file selected";
}
}
}