Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7248465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:08:31+00:00 2026-05-28T22:08:31+00:00

This may be the really wrong way of doing this and so if it

  • 0

This may be the really wrong way of doing this and so if it is please let me know!! I have a user control called ucDropDownList.ascx. It basically is a drop down with a button besides it. When the button is clicked a jquery dialog appears. The dialog is the problem. As this user control is used in a number of places i wanted (within the principles of OOP) to allow us to load in a different form depending on which drop down it was…So i went for Template User Control. The code behind for this is as follows:

public partial class ucDropDownList : System.Web.UI.UserControl

 {

   private ITemplate m_RecordForm = null;

   [TemplateContainer(typeof(cPopUpContainer))]
   [PersistenceMode(PersistenceMode.InnerProperty)]
   public ITemplate RecordForm
   {
     get { return m_RecordForm; }
     set { m_RecordForm = value; }
   }

   protected void Page_Load(object sender, EventArgs e)
   {

   }

   void Page_Init()
   {
     // Load in the Template control (we use this for making the different types of form!
     if (RecordForm != null)
     {
       cPopUpContainer container = new cPopUpContainer();
       m_RecordForm.InstantiateIn(container);
       phNewRecordForm.Controls.Add(container);
     }
   }

   public event EventHandler SaveClicked;
   protected void SaveButton_Clicked(object sender, EventArgs e)
   {
     if (SaveClicked != null)
       SaveClicked(this, e);
   }
 }

 public class cPopUpContainer: Control, INamingContainer
 {
   internal cPopUpContainer()
   {
   }
 }

Then i (will) have several user controls that are simple forms for each of the types that i will have these user controls for…(example given is a status table in the database). There is nothing exciting there, just that all of the controls have viewState Enabled. (pretty much as standard as it comes).

The page that i show these on has some markup like so…

<uc3:ucDropDownList ID="comboStatus" runat="server" OnSaveClicked="comboStatus_Saved">
                    <RecordForm>
                        <uc4:ucEdStatus ID="ucEdStatus1" runat="server" ViewStateMode="Enabled" />
                    </RecordForm>
                </uc3:ucDropDownList>

and a behind the scenes like so…

  protected void Page_Init(object sender, EventArgs e)
  {
     if (!IsPostBack)
    {
      ucEdStatus statForm = comboStatus.Controls[3].Controls[0].FindControl("ucEdStatus1") as ucEdStatus;
      statForm.InitializeControl(false);
    }
   } 

  protected void Page_Load(object sender, EventArgs e)
  {

  }

  protected void comboStatus_Saved(object sender, EventArgs e)
  {
    ucEdStatus statForm = comboStatus.Controls[3].Controls[0].FindControl("ucEdStatus1") as ucEdStatus;
    statForm.SaveRecord(eSaveUCEdType.Insert);
  }

When the SaveRecord runs(this method is a simple insert into the database which is based on the values of the various controls on the ucEdStatus1 control) the controls on the ucEdStatus are all the default as set in the markup and non have maintained what the user put in (therefore the save just saves a wrong bit of data).

I am open to suggestions and criticism. If you need more information i can give it to you, i just need help in understanding why this is happening.

EDIT
Just in case you guys were wondering this is the class for the ucEdStatus control. It may answer why i am still scratching my head or may show how stupid i am.

long m_RecordID
{
  get { return (ViewState["recordid"] != null ? Convert.ToInt64(ViewState["recordid"]) : -1); }
  set { ViewState["recordid"] = value; }
}

bool m_isSupport
{
  get { return (ViewState["isSupport"] != null ? Convert.ToBoolean(ViewState["isSupport"]) : false); }
  set { ViewState["isSupport"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
}

//--------------------------------------------------------------------------------
public void InitializeControl(bool aIsSupport)
{
  //Setup the issupport variable
  m_isSupport = aIsSupport;

  //Add the importance to the mixup...
  Array importanceTexts = System.Enum.GetNames(typeof(eStatusImportance));

  for (int i = 0; i <= importanceTexts.Length - 1; i++)
  {
    ListItem item = new ListItem(importanceTexts.GetValue(i).ToString(), i.ToString());
    comboImportance.Items.Add(item);
  }
}

//--------------------------------------------------------------------------------
public long SaveRecord(eSaveUCEdType aSaveType)
{
  using (cDBConnection con = new cDBConnection(this.Page, true))
  {
    cStatus stat = new cStatus(con.Con, m_RecordID);
    if (m_RecordID == -1)
      stat.Id = cGlobalDB.NewKey();

    stat.Importance = Convert.ToInt32(comboImportance.SelectedValue);
    stat.Name = txtName.Text;
    stat.Issupport = m_isSupport;
    stat.Color = edColor.Color;
    stat.SaveChanges((aSaveType == eSaveUCEdType.Insert ? eUpdateType.insert : eUpdateType.update));
    return (long)stat.Id;
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:08:32+00:00Added an answer on May 28, 2026 at 10:08 pm

    So i found the answer after a little looking around.
    This site really helped. The problem was the jquery modal pop up (dialog) was losing itself on post back. One line fix. How frustrating!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is a really unelegent way of doing what I want, but
This may be a duplicate question, but really don't know how else to word
I may be going about this the wrong way, so I'll set out the
This may not really sound hard to do but it is currently killing me.
This may seem really silly to you, I admit, but when discussing the Model-View-ViewModel
Okay, This may be really simple or it may not even be possible, or
OK, this may be really simple, but it is Friday and it has been
im really new to linq-to-SQL so this may sound like a really dumb question,
Ok, this may seem like a stupid question (for Flash Developers) but I really
I may be missing something here because I thought this might be really easy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.