protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Country = Representatives[0].Country; var countryCode = CountryManager.GetCountryCode(Country); flagImage.ImageUrl = string.Format("~/Images/Flags/{0}.png", countryCode.ToLower()); CountryName.Text = Country; int noOfDisplayedCRepresentatives = 0; int noOfRepresentatives = AppSettings.Representatives.NoOfRepresentatives; Id = Representatives[0].Id; for (int i = 0; i < Representatives.Count && i < noOfRepresentatives; i++) { noOfDisplayedCRepresentatives++; UserControl representativeControl = (UserControl)Page.LoadControl("~/Controls/Representatives/Representative.ascx"); PropertyInfo ctrl = representativeControl.GetType().GetProperty("Representative"); ctrl.SetValue(representativeControl, Representatives[i], null); representativeControl.DataBind(); RepresentativesPlaceHolder.Controls.Add(representativeControl); } RepresentativeCount.InnerText = noOfDisplayedCRepresentatives.ToString() + " " + U6002.REPRESENTATIVES; } }
private UserControl LoadSkin(string SkinPath) { UserControl ctlSkin = null; try { if (SkinPath.ToLower().IndexOf(Globals.ApplicationPath.ToLower()) != -1) { SkinPath = SkinPath.Remove(0, Globals.ApplicationPath.Length); } ctlSkin = (UserControl)LoadControl("~" + SkinPath); // call databind so that any server logic in the skin is executed ctlSkin.DataBind(); } catch (Exception exc) { if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString())) { // only display the error to administrators SkinError.Text += "<div style=\"text-align:center\">Could Not Load Skin: " + SkinPath + " Error: " + Server.HtmlEncode(exc.Message) + "</div><br>"; SkinError.Visible = true; } } return(ctlSkin); }
private UserControl LoadSkin(string SkinPath) { UserControl ctlSkin = null; try { if (SkinPath.ToLower().IndexOf(Globals.ApplicationPath.ToLower()) != -1) { SkinPath = SkinPath.Remove(0, Globals.ApplicationPath.Length); } ctlSkin = (UserControl)LoadControl("~" + SkinPath); // call databind so that any server logic in the skin is executed ctlSkin.DataBind(); } catch (Exception exc) { // could not load user control PageLoadException lex = new PageLoadException("Unhandled error loading page.", exc); if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString())) { // only display the error to administrators SkinError.Text += "<div style=\"text-align:center\">Could Not Load Skin: " + SkinPath + " Error: " + Server.HtmlEncode(exc.Message) + "</div><br>"; SkinError.Visible = true; } Exceptions.LogException(lex); } // check for and read skin package level doctype SetSkinDoctype(SkinPath); return(ctlSkin); }
private void BindConversations() { conversations = user.GetConversations(); ConversationsPlaceHolder.Controls.Clear(); if (conversations.Count == 0) { var noConversationsLiteral = new Literal(); noConversationsLiteral.Text = string.Format("<div class='selected'>{0}</div>", U6000.YOUHAVENOCONVERSATIONS); ConversationsPlaceHolder.Controls.Add(noConversationsLiteral); } else { if (Recipient != null) { SelectedConversation = Conversation.Get(user.Id, Recipient.Id); } else if (SelectedConversation == null) { SelectedConversation = conversations[0]; } for (int i = 0; i < conversations.Count; i++) { UserControl conversationBox = (UserControl)Page.LoadControl("~/Controls/Network/ConversationBox.ascx"); PropertyInfo myProp = conversationBox.GetType().GetProperty("Conversation"); myProp.SetValue(conversationBox, conversations[i], null); conversationBox.DataBind(); var div = new Panel(); var wraper = new LinkButton(); wraper.PostBackUrl = "/user/network/messenger.aspx?cid=" + conversations[i].Id; wraper.Controls.Add(conversationBox); wraper.CommandArgument = conversations[i].Id.ToString(); div.Controls.Add(wraper); ConversationsPlaceHolder.Controls.Add(div); if (conversations[i].Id == SelectedConversation.Id) { div.CssClass = "selected bg-info"; } else { div.CssClass = ""; } } } }
private void LoadPosts() { var posts = profileOwner.GetPosts(); PostsPlaceHolder.Controls.Clear(); for (int i = 0; i < posts.Count; i++) { UserControl postControl = (UserControl)Page.LoadControl("~/Controls/Network/Post.ascx"); PropertyInfo myProp = postControl.GetType().GetProperty("Post"); myProp.SetValue(postControl, posts[i], null); postControl.DataBind(); PostsPlaceHolder.Controls.Add(postControl); } }
void LoadOffers() { var cpaOffers = externalOfferWallsManager.CpaOffers; OffersPlaceHolder.Controls.Clear(); foreach (var offer in cpaOffers) { UserControl offerControl = (UserControl)Page.LoadControl("~/Controls/Advertisements/ExternalCpaOffer.ascx"); PropertyInfo myProp = offerControl.GetType().GetProperty("CpaOffer"); myProp.SetValue(offerControl, offer, null); offerControl.DataBind(); OffersPlaceHolder.Controls.Add(offerControl); ((IExternalCpaOfferControl)offerControl).SubmitButtonClicked += CpaOfferControl_SubmitButtonClicked; } }
private void BindFriends() { members = Friendship .GetList(profileOwner.Id) .Select(x => new Member(profileOwner.Id == x.UserIdOne ? x.UserIdTwo : x.UserIdOne)) .ToList(); for (int i = 0; i < members.Count; i++) { UserControl friendInfoControl = (UserControl)Page.LoadControl("~/Controls/Network/FriendInfo.ascx"); PropertyInfo member = friendInfoControl.GetType().GetProperty("Friend"); member.SetValue(friendInfoControl, members[i], null); friendInfoControl.DataBind(); FriendInfoPlaceHolder.Controls.Add(friendInfoControl); } }
protected void BindRepresentatives(List <Representative> representatives, List <string> countries, int iterator, string bindConcretCountry = null) { UserControl countryControl = (UserControl)Page.LoadControl("~/Controls/Representatives/RepresentativeCountry.ascx"); PropertyInfo ctrl = countryControl.GetType().GetProperty("Representatives"); if (String.IsNullOrEmpty(bindConcretCountry)) { ctrl.SetValue(countryControl, representatives.Where(item => item.Country == countries[iterator]).ToList(), null); } else { ctrl.SetValue(countryControl, representatives.Where(item => item.Country == bindConcretCountry).ToList(), null); } countryControl.DataBind(); CountriesPlaceHolder.Controls.Add(countryControl); }
private void BindUsers() { UserControl.DataValueField = "UserId"; UserControl.DataTextField = "UserName"; UserControl.DataSource = BusReport.GetUsers(GetFromDate(), GetToDate()); UserControl.DataBind(); if (UserControl.Items.Count > 0) { UserControl.Value = new string[] { "0" } } ; // any else { UserControl.Value = new string[] { } }; // not set BindClients(); }
protected void Page_Load(object sender, EventArgs e) { if (!AppSettings.Site.LatestNewsEnabled) { Response.Redirect("~/user/default.aspx"); } int newsId; if (!int.TryParse(Request.QueryString["news"], out newsId) && TableHelper.SelectScalar(string.Format("SELECT * FROM Texts WHERE TextType = {0}", (int)WebsiteTextType.NewsNote)) != null) { newsId = (int)TableHelper.SelectScalar(string.Format("SELECT TOP 1 TextId FROM Texts WHERE TextType = {0} ORDER BY LastModifiedDate DESC", (int)WebsiteTextType.NewsNote)); } var whereNewsNotes = TableHelper.MakeDictionary("TextId", newsId); var news = TableHelper.SelectRows <WebsiteText>(whereNewsNotes); if (news.Count == 0) { NoNewsPlaceHolder.Visible = true; } else { NewsPlaceHolder.Visible = true; if (news.Count == 1) { //Display the news TitleLiteral.Text = news[0].Title; DateLiteral.Text = news[0].Created.ToString(); TextLiteral.Text = news[0].Content; } UserControl newsControl = (UserControl)Page.LoadControl("~/Controls/News.ascx"); PropertyInfo newsProperty = newsControl.GetType().GetProperty("NewsInFeed"); newsProperty.SetValue(newsControl, 4, null); newsControl.DataBind(); LatestNewsPlaceHolder.Controls.Add(newsControl); } }
void LoadOfferWalls() { var offerWalls = ptcOfferWallManager.GetOfferWalls(); if (offerWalls.Count == 0) { HandleUnauthorizedRequest(); return; } OffersPlaceHolder.Controls.Clear(); foreach (var offer in offerWalls) { UserControl offerControl = (UserControl)Page.LoadControl("~/Controls/Advertisements/PtcOfferWall.ascx"); PropertyInfo myProp = offerControl.GetType().GetProperty("OfferWall"); myProp.SetValue(offerControl, offer, null); offerControl.DataBind(); OffersPlaceHolder.Controls.Add(offerControl); } }
private void LoadComments() { CommentsPlaceHolder.Visible = true; CommentsDiv.Controls.Clear(); for (int i = 0; i < comments.Count; i++) { UserControl commentControl = (UserControl)Page.LoadControl("~/Controls/Network/Comment.ascx"); PropertyInfo comment = commentControl.GetType().GetProperty("Comment"); comment.SetValue(commentControl, comments[i], null); PropertyInfo post = commentControl.GetType().GetProperty("Post"); post.SetValue(commentControl, Post, null); ((ICommentObjectControl)commentControl).DeleteButtonClicked += CommentControl_DeleteButtonClicked; commentControl.DataBind(); CommentsDiv.Controls.Add(commentControl); } }
/// <summary> /// Handles the Command event of the btnDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param> protected void btnDelete_Command(object sender, CommandEventArgs e) { if (String.Compare(e.CommandName, "Delete", true) == 0) { // get the file GridServerTemplateContainer container = this.Parent as GridServerTemplateContainer; if (container != null) { object obj = container.DataItem[FilePathArgument]; if (obj != null) { string filePath = obj.ToString(); if (File.Exists(filePath)) { // delete file try { File.Delete(filePath); } catch (Exception ex) { // TODO: handle exception here // Dummy call on ex to suppress warning ex.ToString(); } } } } } // rebind control that contains parent grid UserControl parentControl = this.Parent.Parent.Parent as UserControl; if (parentControl != null) { parentControl.DataBind(); } }
private void BindFriends() { members = Friendship .GetList(Member.CurrentId) .Select(x => new Member(Member.CurrentId == x.UserIdOne ? x.UserIdTwo : x.UserIdOne)) .ToList(); for (int i = 0; i < members.Count; i++) { UserControl friendInfoControl = (UserControl)Page.LoadControl("~/Controls/Network/FriendInfo.ascx"); PropertyInfo member = friendInfoControl.GetType().GetProperty("Friend"); member.SetValue(friendInfoControl, members[i], null); if (Request.QueryString["conv"] != null) { friendInfoControl.GetType().GetProperty("RedirectToMessenger").SetValue(friendInfoControl, true, null); } friendInfoControl.DataBind(); FriendInfoPlaceHolder.Controls.Add(friendInfoControl); } }
private void BindFriends() { members = new List <Member>(); try { members = TableHelper.GetListFromRawQuery <Member>( String.Format("SELECT * FROM Users WHERE Username LIKE '%{0}%'", query)); } catch (Exception ex) { } NoResultsPlaceHolder.Visible = (members.Count == 0); for (int i = 0; i < members.Count; i++) { UserControl friendInfoControl = (UserControl)Page.LoadControl("~/Controls/Network/FriendInfo.ascx"); PropertyInfo member = friendInfoControl.GetType().GetProperty("Friend"); member.SetValue(friendInfoControl, members[i], null); friendInfoControl.DataBind(); FriendInfoPlaceHolder.Controls.Add(friendInfoControl); } }