Hello everyone,
I am having some problems with this page that has a Placeholder control inside an UpdatePanel control. When the updatepanel is triggered, then the page seems to do a full postback and I end up with 2 sets of controls added to the page instead of 1.
Here is where I'm creating the updatepanel and placeholder:
<asp:UpdatePanel ID="upd3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="plhSemesters" Runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnSave2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Here is the code behind:
protected void Page_Load(object sender, EventArgs e)
{
...
if (!IsPostBack)
{
//Enable Save Buttons
btnSave1.Enabled = true;
btnSave2.Enabled = true;
//Set Course Title
lblCourseTitle.Text = crs.courTitle;
}
//Display Semesters and each Location
ArrayList sems = Semester.getSemesterList(D
ateTime.No
w, sqlCon);
DisplaySemesters(crs, sems, sqlCon);
...
}
private void DisplaySemesters(Course crs, ArrayList Semesters, SqlConnection sqlCon)
{
//Go through each semester, and display all location frequencies
plhSemesters.Controls.Clea
r();
...
//TextBox for Course Frequency
TextBox txtCFLoc = new TextBox();
txtCFLoc.ID = "txt" + sem.semId + loc.locId;
txtCFLoc.CssClass = "TextBox";
txtCFLoc.MaxLength = 2;
...
if (i % 2 == 0) { plhSemesters.Controls.Add(
new LiteralControl("<tr class='ItemRow1'>")); }
else { plhSemesters.Controls.Add(
new LiteralControl("<tr class='ItemRow2'>")); }
plhSemesters.Controls.Add(
new LiteralControl("<td vAlign='middle' align='left' width='25%' class='LabelBold'>" + loc.locCity + "</td>"));
plhSemesters.Controls.Add(
new LiteralControl("<td vAlign='middle' align='left' width='10%'>"));
plhSemesters.Controls.Add(
txtCFLoc);
plhSemesters.Controls.Add(
new LiteralControl("</td>"));
plhSemesters.Controls.Add(
new LiteralControl("<td vAlign='middle' align='left' width='65%'></td>"));
plhSemesters.Controls.Add(
new LiteralControl("</tr>"));
...
}
When I click on one of the linkbuttons to trigger the updatepanel, I get a full page postback and 2 sets of controls.
Is there a bug with the updatepanel and placeholder controls or am I doing something wrong?
Start Free Trial