Hi,
I have the following structure in place and need to rebind the lower control (DropDownList) from the code behind of the MainPage.
x MainPage1 x---- Panel1 (modal popup)
x--------- UpdatePanel (upMailOrStatusAction, on Panel1)
x-------------- RadioButtonList (rblActionLevel, on UpdatePanel)
x-------------- SubForm1 (on Panel1)
x------------------- CustomControl1 (on Subform1)
x------------------------ DropDownList (on CustomControl1)
What would be the correct way to accomplish this?
I added a public method "BindMailActionLookup()" to the control, but how do I call it from the main page? I get "does not exist in the current context"?
Here is the markup of the subform:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MailAddSubform.ascx.cs"
Inherits="Company.Solutions.Web.Controls.MailAddSubform" %>
<%@ Register TagPrefix="st" TagName="MailActionLookup" Src="~/Controls/StMailActionLookup.ascx" %>
<div class="NinetyNinePercentWide">
<div class="NinetyNinePercentWide EightPixelBottomMargin">
<div class="RowHeader" style="padding-top: 20px;">
<span class="labelfield" >Action:</span>
</div>
<div>
<st:MailActionLookup ID="mailActionLookup" runat="server" />
</div>
</div>
<div class="NinetyNinePercentWide EightPixelBottomMargin" >
<br class="NinetyNinePercentWide" Text=" " />
<div class="RowHeader" >
<span class="labelfield" >Message:</span>
</div>
<div class="TwelvePixelLeftPad" >
<asp:TextBox ID="txtMailActionMessage" runat="server" MaxLength="40" />
</div>
</div>
</div>
Here is the markup for the custom control:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StMailActionLookup.ascx.cs" Inherits="Company.Solutions.Web.Controls.StMailActionLookup" %>
<div id="mainControlContainer" style="width:99%; padding:8px;">
<div id="comboContainer" style="float:left; padding-top:12px;padding-left:5px; padding- right:5px; padding-bottom:3px;">
<asp:UpdatePanel runat="server" ID="mailActionUpdater">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="chkForms" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkRequested" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="chkOther" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList runat="server" ID="ddlLookup" width="240px" ondatabound="ddlLookup_DataBound1" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="filterContainer" style="text-align:left;padding-left:6px;width:275px">
<fieldset style="width:260px;">
<legend>Filters</legend>
<asp:CheckBox ID="chkForms" runat="server" Text="Forms" AutoPostBack="true" />
<asp:CheckBox ID="chkRequested" runat="server" Text="Requested Info" AutoPostBack="true" />
<asp:CheckBox ID="chkOther" runat="server" Text="Other" AutoPostBack="true" />
</fieldset>
</div>
</div>
And here is part of the code behind where I added the public method:
namespace Company.Solutions.Web.Controls
{
public partial class StMailActionLookup : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
BindForm();
}
public void BindMailActionLookup()
{
BindForm();
}
protected void BindForm()
{
GetActionLevel();
IEnumerable actions = GetClaimMailActions(GetFilter());
ddlLookup.DataSource = actions;
ddlLookup.DataTextField = "CodeAndDescription";
ddlLookup.DataValueField = "ActionCd";
ddlLookup.DataBind();
}
}
}
Thank you, James