protected void Page_Load(object sender, EventArgs e) { Page.MaintainScrollPositionOnPostBack = true; Page.Form.Attributes.Add("enctype", "multipart/form-data"); if (User.Identity.IsAuthenticated) { var db = new Model1(); subjectID = Convert.ToInt32(Request.QueryString["subjectID"]); subject = (from subjects in db.subjects where subjects.SubjectID == subjectID select subjects).FirstOrDefault(); //string pass = (string)(from subjects in db.Subjects where subjects.SubjectID == subjectID select subjects.SubjectPassword).Single<string>(); if (subject.IsPrivate) { string userID = User.Identity.GetUserId(); //int count = (from joinSubjectUser in db.JoinSubjectUser where joinSubjectUser.SubjectID == subjectID && joinSubjectUser.UserID == userID select joinSubjectUser.SubjectID).Count(); joinsubjectusers member = (from joinSubjectUser in db.joinsubjectusers where joinSubjectUser.SubjectID == subjectID && joinSubjectUser.UserID == userID select joinSubjectUser).SingleOrDefault(); if (member == null) { Response.Redirect("~/SubjectPassword.aspx?SubjectID=" + subjectID); } } updatePanel = (UpdatePanel)Page.FindControlRecursive("UpdatePanel"); blockList = (ListView)Page.FindControlRecursive("blockList"); resourceList = (ListView)Page.FindControlRecursive("resourceList"); if (User.IsInRole("Profesor") || User.IsInRole("admin")) { if (subject.IsPrivate) { Button makePublicButton = (Button)Page.FindControlRecursive("MakePublic"); makePublicButton.Visible = true; Button changePassword = (Button)Page.FindControlRecursive("ChangePassword"); changePassword.Visible = true; } else { Button makePrivateButton = (Button)Page.FindControlRecursive("MakePrivate"); makePrivateButton.Visible = true; } } Label subjectName = (Label)Page.FindControlRecursive("subjectName"); subjectName.Text = subject.SubjectName; if (subject.IsPrivate) { Button leaveButton = (Button)Page.FindControlRecursive("LeaveButton"); leaveButton.Visible = true; } } }
public void ShowSubjectPanel(object sender, EventArgs e) { ModalPopupExtender modalPopupExtender = (ModalPopupExtender)Page.FindControlRecursive("EditSubjectPopup"); modalPopupExtender.Show(); TextBox name = (TextBox)Page.FindControlRecursive("EditSubjectName"); using (Model1 _db = new Model1()) { Models.subjects sub = (from subjects in _db.subjects where subjects.SubjectID == subjectID select subjects).FirstOrDefault(); name.Text = sub.SubjectName; updatePanel.Update(); } }