Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Refresh problem on a control
Message
From
08/01/2010 17:33:58
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Refresh problem on a control
Environment versions
Environment:
ASP.NET
OS:
Windows Server 2008
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01442880
Message ID:
01442880
Views:
112
I have a web I am currently working on that I have published a first pass on. One of my pages contains a control which displays bio content along with a photograph. Both the bio content and the photo come from a SQL Server 2008 database. If there is no photo available, a placeholder photo is displayed. The problem is when you click on one bio name you see the photo but when you click on another the photo doesn't change. However if you click on a name which does not have a photo it changes to the placeholder. Once you get that, you can click back on a name with a photo and get it. I am struggling to see what is causing this behavior. I am posting some of my code if someone else sees why that might happen. The bio content portion always is displayed properly. Both the photo and the bio are on the same control.
Thanks
Tim

This is the code in the control itself.
 public partial class ucAboutBiography : AUserControl
    {
        protected PageContent oContent;
        protected MSA.Main.Business.Contact oContact; // Conflicts with "Contact" us page

        public override void Setup(string contentLookup)
        {
            this.GetBioContent(contentLookup);
        }

        private void GetBioContent(string lookup)
        {
            this.oContent = new PageContent();
            this.oContent.GetContentByContentLookup("BIO", lookup);

            if (this.oContent.Entity.HasValues)
            {
                this.lblName.Text = this.oContent.Entity.ContentName;
                this.lblTitle.Text = this.oContent.Entity.ContentDescription;
                this.BioContent.Text = this.oContent.Entity.ContentText;

                // Get the photo if there is one
                if (this.oContent.Entity.ContributorID != null)
                {
                    Session["contactid"] = this.oContent.Entity.ContributorID.ToString();
                    this.imgBoardPhoto.ImageUrl = @"~/ShowPhoto.aspx";
                }
            }
            else
            {
                this.lblName.Text = "Biography Not Found";
                this.lblTitle.Text = "";
                this.BioContent.Text = "";
                this.imgBoardPhoto.ImageUrl = @"~/Images/ComingSoon.jpg";
            }
        }

    } // End of Class
Then here is the code in the ShowPhoto.aspx that shows the photo.
 public partial class ShowPhoto : mmBusinessWebPage
    {
        /// <summary>
        /// Page Load Handler
        /// </summary>
        /// <param name="sender">Event Source</param>
        /// <param name="e">Event Args</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Clear();
            Response.ContentType = "image/pjpeg";

            if (Session["contactid"] != null)
            {
                Guid contactId = new Guid(Session["contactid"].ToString());

                var oContact = new MSA.Main.Business.Contact();
                oContact.GetContactByID(contactId);

                // Show the Photo
                Response.BinaryWrite(oContact.Entity.DocumentPhoto);
            }
            else
            {
                Response.WriteFile(@"~/Images/ComingSoon.jpg");
            }
            Response.End();
        }
    }
Since the bio control is displayed fine and the bio content is displayed and updates fine I didn't post any of the code that deals with placing the control from the hosting page.

You can see this in action at http://www.msatexas.com and then click on the about tab then on the left menu expand the board members and click on different board members names.
Tim
Timothy Bryan
Next
Reply
Map
View

Click here to load this message in the networking platform