ISettingControl losing populated value before saving.

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
3/29/2018 1:02:16 PM
Gravatar
Total Posts 32

ISettingControl losing populated value before saving.

I have a new issue that wasn't an issue before. I have a feature setting control that populates a drop down menu at run-time. It was working before when I was on v2.4 and now suddenly it's no longer working on v2.6. I did a trace on the code, and realized it's losing the populated values when trying to pull the value. Code is below. Is this a bug, or am I missing something?

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack && ddlFormList.Items.Count == 0) LoadFormList();
}

private void LoadFormList()
{
    foreach (string form in Directory.GetDirectories(FormFolderPath))
    {
        string formName = form.Substring(form.LastIndexOf("\\") + 1);
        ddlFormList.Items.Add(new ListItem(formName, formName));
    }
}

#region ISettingControl

public string GetValue()
{
    return ddlFormList.SelectedValue; //All populated values are lost here.
}

public void SetValue(string value)
{
    if (ddlFormList.Items.Count == 0) LoadFormList();
    ListItem item = ddlFormList.Items.FindByValue(value);
    if (item != null)
    {
        ddlFormList.ClearSelection();
        item.Selected = true;
    }
}
3/29/2018 2:38:23 PM
Gravatar
Total Posts 32

Re: ISettingControl losing populated value before saving.

I found the issue. I needed to put my populating code in the Page_Init event, instead of the Page_Load event. Recommend that be added to the developer documentation for future reference.

You must sign in to post in the forums. This thread is closed to new posts.