YAFLogo

vcsharp
  • vcsharp
  • 88.4% (Honored)
  • YAF Commander Topic Starter
7 years ago
Steps to reproduce this issue.

1. On Edit Profile page select a country like United States or any other country. One can see flag images in this step.

2.After step 1, ajax postback occurs and after the request finishes, open the Country drop down and you will see that images are missing.

A video of this issue can be seen at Video of this Issue 

Sponsor
vcsharp
  • vcsharp
  • 88.4% (Honored)
  • YAF Commander Topic Starter
7 years ago
I was able to resolve this issue. All that was needed was to set the property ImageLocation property of Country ImageListBox. This property was set in code-behind when EditProfile page first loaded in BindData( ) method, but it is not being persisted across postbacks. So when Country drop down makes an ajax postback, in the Render method of ImageListBox.cs control, this property is blank.

So, I set it in markup for this control in controls/EditUserProfile.ascx user control and then on ajax postback the images for countries are still visible. I have tested and tried this code.


       <td class="post">
            <YAF:ImageListBox ID="Country" AutoPostBack="true" 
                        OnTextChanged="LookForNewRegions" runat="server" 
                       CssClass="selectMenuWithIcons" 
                       ImageLocation="/Content/images/flags/{0}.png"/>
        </td>

But, I think a better option would be to persist the property ImageLocation in ImageListBox control by using sample code as below. I have tested this code also and it works. This will take care of regular as well as ajax postbacks from ImageListBox on all pages unlike the first solution that will work only on a single page.

Code change in ImageListBox.cs in YAF.Controls project


        public string ImageLocation
        {
            get
            {
                string imageLocation = ViewState["ListBoxImageLocation"] as string;
                return string.IsNullOrWhiteSpace(imageLocation) ? string.Empty : imageLocation;
            }
            set
            {
                ViewState["ListBoxImageLocation"] = value;
            }
        }

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
7 years ago
Thanks issue will be fixed in the next release.