0

I am running SP2013 SP1 August 2016 CU. I have a solution with a page in it which has some text fields in it. I write some content to those text fields as the result of a drop down list item being selected, on the same page. But the contents of those fields (all fields I populate using C#) are not displayed. Yet, I can debug the code and see those fields being populated. What am I doing wrong ? Do I need to refresh the pages (how without losing the drop down list item ). Or do I use update panels (conditional or unconditional)?

This is the page :-

<%@ Register TagPrefix="sbwCtl" Namespace="ABC.SP.xxxxx.ControlTemplates" Assembly="ABC.SP.xxxxxxxxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3405ca806bd3483f" %>

<%@ Register Src="../../../_controltemplates/15/SBW/SBWyyyyyyyControl.ascx" TagPrefix="uc1" TagName="SBWyyyyyyyyControl" %>

<asp:UpdatePanel ID="sbwUpdatePanel" runat="server" >
            <ContentTemplate>
        <div class="sbw">
                <div id="sbw-banner">
                    <asp:Image ImageUrl="/_layouts/15/sbw/images/sbwbanner.png" runat="server" Width="900px" Height="180px" />
                    <h1>

                    </h1>
                </div>
                  <table>
                            <tr>
                                <td>
                                    Template ID
                                </td>
                                <td>
                                    <asp:Text ID="lblTemplateIdP2" runat="server" ></asp:Text>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Template Display Name
                                </td>
                                <td>
                                    <asp:Text ID="lblTemplateDisplayNameP2" runat="server"></asp:Text>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Template Description
                                </td>
                                <td>
                                    <asp:Text ID="lblTemplateDescriptionP2" runat="server"></asp:Text>
                                </td>
                            </tr>
                            <tr>
                                <p style="color:red;font-weight:bold"><asp:Label ID="lblUserArea" runat="server" Text=""></asp:Label></p>
                            </tr>
                        </table>

The code I am using to populate the text Boxes is :-

              this.lblTemplateIdP2.Text = CurrentSite.Title;
              this.lblTemplateDIsplayNAmeP2.Text = CurrentSite.Description;

SO why are my textboxes not being populated on the screen ?

Thanks

Nigel

More Info as requested by @M.Qassas

        public void PopulateSiteDropDown(List<XXXSiteInstance> sitesToBeDisplayed, int selectedItem)
    {
        string sLogSource = " Site - Populate";
         try
        {
            this.ddlSiteDisplayName.Items.Clear();
            this.ddlSiteDisplayName.Items.Add("--");

            foreach (XXXSiteInstance site in sitesToBeDisplayed)
            {
               this.ddlSiteDisplayName.Items.Add(site.Title);
            }
            // Set combo box selected index either to -1 (if selected item is null) or the value of selected item)
            if(selectedItem == null)
                this.ddlSiteDisplayName.SelectedIndex = -1;
            else
                this.ddlSiteDisplayName.SelectedIndex = selectedItem;

        }
        catch (Exception ex)
        {
            sbwLogger.LogError(sLogSource, ex.Message);
        }

    }      

This is what is called when an Item in the drop down list is selected :

        protected void ddlSiteDisplayName_SelectedValueChanged(object sender, EventArgs e)
    {
        if (this.ddlSiteDisplayName.SelectedIndex != -1)
        {
            // Set the Current Site Collection name to the changed Value
            this.CurrentProvisioningSiteName = this.ddlSiteDisplayName.SelectedValue.ToString();
            if (this.CurrentProvisioningSiteName == "New")
            {

            }
            else
            {
                if(this.CurrentProvisioningSite == -1)  // No Top Level Site Selected yet
                this.CurrentProvisioningSite = this.ddlSiteDisplayName.SelectedIndex - 1;   // cos "0" is "New"
            }
            LoadSiteSettings();
        }
    }

Where LoadSiteSettings loads the settings of the item in the drop down list that was selected.

The class of the C# code is as follows :-

public partial class XXXXWizardPage : LayoutsPageBase

1
  • Hi @nigel where you fill your dropdown list ? and what's the action that should happen when an item selected ? should you post full code with more details to can help you faster ? Nov 13, 2016 at 21:38

1 Answer 1

0

Please try updating the update panel on drop down selection

sbwUpdatePanel.update();
3
  • I presume I need updatemode=conditional on the <asp:UpdatePanel statement on my .aspx page Nov 14, 2016 at 9:36
  • Yes <asp:UpdatePanel ID="sbwUpdatePanel" runat="server" UpdateMode="Conditional">
    – Sunil Sahu
    Nov 14, 2016 at 9:42
  • That looks as if that was the problem thanks @Robert Lindgren and Sunil sahu Nov 14, 2016 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.