Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
User Controls When to set the value of controls
Message
From
29/07/2009 18:08:17
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP SP2
Application:
Web
Miscellaneous
Thread ID:
01414924
Message ID:
01415416
Views:
27
>>
>>I am loading the user control at the end of the Page_Load via a seperate method that also gets called from the grid selected index change. The control is inside an ajax panel so only the panel gets refreshed.
>
>(I'm assuming an UpdatePanel?) - is it possible it's not detecting the changes correctly and not rendering the changes to the page? Maybe temporarily remove the updatepanel and try it. Is your postback happening from a control within the update panel? If not, you may have to set a trigger on the UpdatePanel so it knows when it needs to refresh (heck, you may have to do that even if it's inside of the UpdatePanel).


At this point my controls are null within my user control from the PreRender of my user control even when first loaded. I do have an ajax panel on my page where the user control is placed, but it works as long as I reference my values in the Page Load instead.

Here is the code in my User Control
protected void Page_Load(object sender, EventArgs e)
{
     // Works here
     this.lblAffiantName.Text = this.Affiant;
     // Extra code removed
}

protected void Page_PreRender(object sender, EventArgs e)
{
     if (this.ArrestRecord != null)
          this.DisplayAffiant();
}

public void DisplayAffiant()
{
     // Moved to the Page Load, doesn't work here for some reason, lblAffiantName is null

     //this.lblAffiantName.Text = this.Affiant;
     // extra code removed
}

public void SetupAffiant(ArrestEntity entity)
{
     // Store the Arrest Record into the property
     this.ArrestRecord = entity;

     // Format and store the Affiant Name
     string[] affiantNameParts = new string[] {
     entity.caffiant_title,
     entity.caffiant_first_name,
     entity.caffiant_last_name};

     this.Affiant = Utility.FormatName(affiantNameParts);
     // Extra code removed
}
Here is the code where I am putting it on the page
protected void Page_Load(object sender, EventArgs e)
{
     this.oArrest = (Arrest)RegisterBizObj(new Arrest());
     // Lots of code removed

     if (!IsPostBack) 
     {
           // Verify we have a Case Record
           if (this.oCase.Entity.HasValues)
          {
               this.DisplayCurrentArrest(arrestID);
          }
     }
}

private void DisplayCurrentArrest(Guid arrestID)
{
     // Lots of code removed
     // Call the display of Affiant Control
     // The entity column is set as nullable, thus the extra coding here
     this.DisplayAffiantControl(this.oArrest.Entity.laffiant_is_civilian == true ? true : false);
}

protected void DisplayAffiantControl(bool isCivilian)
{
     if (isCivilian)
     {
          ctrlCivilianAffiant civilAffiant =
               (ctrlCivilianAffiant)Page.LoadControl("~/UserControls/ctrlCivilianAffiant.ascx");
          civilAffiant.SetupAffiant(this.oArrest.Entity);
          this.holdAffiant.Controls.Add(civilAffiant);
     }
     // Other options all removed
}
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform