DevExpress CallbackPanel takes forever to load data - asp.net

I have a user control within a child page within a master page in which I need a panel to be displayed according to a check box's checked status.
I could use jQuery to accomplish this, but I need Ajax. Now if you are familiar with DX CallbackPanel you know that this control is just like the ASP.NET update panel.
When I check my check box I call a JavaScript function that calls the CallbackPanel.PerformCallback() function, and this function does what it does.
This is my user control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="dx_auto_saxs_sales.ascx.cs" Inherits="bime.shokri.v1._0._1.Forms.dx_auto_saxs_sales" %>
<%# Register Assembly="DevExpress.Web.v15.2, Version=15.2.10.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<script type="text/javascript">
var CallbackInQue = false;
function CheckBoxBimeSalQabl_CheckedChanged(s,e)
{
if (ASPxCallbackPanel.InCallback())
CallbackInQue = true;
else
ASPxCallbackPanel.PerformCallback();
}
function OnEndCallback(s,e)
{
if(CallbackInQue)
{
ASPxCallbackPanel.PerformCallback();
CallbackInQue = false;
}
}
</script>
<dx:ASPxCheckBox ID="ASPxCheckBox2" runat="server" Theme="MetropolisBlue" Text="بیمه نامه سال قبل دارد" Font-Names="yekan" CheckState="Unchecked" ClientInstanceName="ChechBoxBimeSalQabl">
<ClientSideEvents CheckedChanged="CheckBoxBimeSalQabl_CheckedChanged" />
</dx:ASPxCheckBox>
<dx:ASPxCallbackPanel ID="ASPxCallbackPanel" runat="server" ClientInstanceName="ASPxCallbackPanel">
<SettingsLoadingPanel Text="صبر کنید&hellip;" />
<ClientSideEvents EndCallback="OnEndCallback" />
<PanelCollection>
<dx:PanelContent runat="server">
<asp:Panel runat="server" ID="pnl_formerBimeName">
<div class="three fields">
<div class="field">
<label>تعداد سال های تخفیف <span style="color: #c66050">●</span></label>
<dx:ASPxComboBox ID="ASPxComboBox7" runat="server" ValueType="System.String" BackColor="#efefef" CssClass="round-corner-control" Theme="MetropolisBlue" Font-Names="yekan" NullText="انتخاب کنید" Width="90%">
<Items>
<dx:ListEditItem Text="1 سال عدم خسارت" Value="0" />
</Items>
</dx:ASPxComboBox>
</div>
</div>
</asp:Panel>
</dx:PanelContent>
</PanelCollection>
</dx:ASPxCallbackPanel>
The purpose is to display Panel(pnl_formerBimeName) when CheckBox is checked.
Now this is my Page_Load(sender,object) method which is called asynchronous when Checkbox is checked:
protected void Page_Load(object sender, EventArgs e)
{
pnl_formerBimeName.Visible = ASPxCheckBox2.Checked;
}
Everything is OK until I deploy my website to my server. After that when I check the checkbox the "Loading..." the text appears and takes forever to complete. I really don't know why.
Just in case you wonder about this problem in action, I give you the mentioned page here.

Related

how to access textbox value to code behind using asp.net Content Page?

i have a textbox and a button in my aspx file,i want to get the textbox value to code behind while clicking the button,I implemented this before,but now iam using asp:content pages,but now i cant get the value to codebehind
my aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="test1.test" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<body>
<div>
<input type="text" runat="server" id="abc" />
<asp:Button
ID="Button1"
runat="server"
Text="Search"
class="btn"
OnClick="Button1_Click"
/>
</div>
</body>
</asp:Content>
My aspx.cs
protected void Button1_Click(Object sender,
System.EventArgs e)
{
string txtboxvalue = Request.Form["abc"];
}
but i cant get the textbox value in button click.
Since you have already given runat to your input control,
<input type="text" runat="server" id="abc" />
You can access the value of text like this
string txtboxvalue = abc.Value;
//Here no need of using Request.Form since input is now a server control
Your control doesn't have a name, so it doesn't get POSTed in the form that you can read it as Request.Form["abc"]. WebForms will generate its name, something like master00$formName$abc. You can check this in the HTML source, but it may be different per request or change after you add more controls on the page. So you should not use this field when it's autogenerated.
Either give it a name:
<input type="text" runat="server" id="abc" name="abc" />
Or, because it's runat="server" and has an id, you can simply access it from code behind:
string textBoxValue = abc.Value;

Cannot perform close/open ASP.Net Ajax ModalPopupExtenders in sequence from server side code

I'm having a problem hiding one ModalPopupExtender and Showing another within the same server-side call.
My app requires user input on some validating conditions. These conditions are evaluated in sequence and when certain conditions are true it requires a user to verify (click yes or no) via a ModalPopupExtender window. If the user clicks Yes, evaluation should continue and if another condition requires user input it should also open a modal dialog - until all conditions are passed.
I've got no problem if only one of the conditions requires input, but if more than one require input, only the first modal is displayed and I can't figure out why. When tracing the code it's clear that the Hide() on the first popup is hit and the Show() on the second popup is hit, but the second popup never shows up.
I've tried to pull out the relevant code blocks here with extreme simplification. It's a really complex project and I may have missed something but I hope it's enough to describe my problem.
Problematic process flow:
User clicks "Continue" -> DoContinue is called -> set conditions flags -> Show first modal popup -> Return to user
User clicks "Yes" -> calls condition 1 Yes click handler (set handled flag, hide modal popup) -> call DoContinue-> re-evaluate conditions flags -> attempt to show second modal popup -> return to user.
The first popup disappears but the second is never shown.
It's only a problem when Hide() is being called on the first modal in the same request where Show() is being called on the second.
MyContainerControl.ascx:
<%# Control Language="C#" AutoEventWireup="true" Inherits="MyContainerControl" %>
<input Type="Submit"
id="btnContinue"
Name="btnContinue"
Value="Continue"
OnServerClick="Continue_Click"
runat="server"/>
<asp:UpdatePanel
ID="updateCondition1"
runat="server"
ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<ajaxToolkit:ModalPopupExtender
ID="modalCondition1"
runat="server"
BehaviorID="dlgCondition1"
TargetControlID="btnFakeInvokeModalCondition1"
PopupControlID="divCondition1"
BackgroundCssClass="modalBackground"
DropShadow="true"
PopupDragHandleControlID="divDragCondition1"
RepositionMode="RepositionOnWindowResize"
CancelControlID="btnCondition1No" />
<input type="button"
id="btnFakeInvokeModalCondition1"
runat="server"
style="display: none" />
<div id="divCondition1"
runat="server"
class="modalPopup">
<custom:Condition1Control id="condition1" runat="server" visible="false" />
<div id="divDragCondition1"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel
ID="updateCondition2"
runat="server"
ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<ajaxToolkit:ModalPopupExtender
ID="modalCondition2"
runat="server"
BehaviorID="dlgCondition2"
TargetControlID="btnFakeInvokeModalCondition2"
PopupControlID="divCondition2"
BackgroundCssClass="modalBackground"
DropShadow="true"
PopupDragHandleControlID="divDragCondition2"
RepositionMode="RepositionOnWindowResize"
CancelControlID="btnCondition2No" />
<input type="button"
id="btnFakeInvokeModalCondition2"
runat="server"
style="display: none" />
<div id="divCondition2"
runat="server"
class="modalPopup">
<custom:Condition2Control id="condition2" runat="server" visible="false" />
<div id="divDragCondition2"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
MyContainerControl.cs:
public class MyContainerControl : System.Web.UI.UserControl
{
protected HtmlInputImage btnContinue;
//Condition1
protected AjaxControlToolkit.ModalPopupExtender modalCondition1;
protected UpdatePanel updateCondition1;
protected HtmlGenericControl divCondition1;
protected Condition1Control condition1;
//Condition2
protected AjaxControlToolkit.ModalPopupExtender modalCondition2;
protected UpdatePanel updateCondition2;
protected HtmlGenericControl divCondition2;
protected Condition2Control condition2;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
condition1.Condition1RaisedEvent += HandleCondition1Event;
condition2.Condition2RaisedEvent += HandleCondition2Event;
btnContinue.ServerClick += btnContinue_ServerClick;
}
protected void HandleCondition1Event(object sender, Condition1EventArgs e)
{
// use ship to store
ViewState["Condition1Yes"] = true;
ViewState["Condition1Value"] = e.Condition1Value;
modalCondition1.Hide();
DoContinue(sender);
}
protected void HandleCondition2Event(object sender, Condition2EventArgs e)
{
// use ship to store
ViewState["Condition2Yes"] = true;
ViewState["Condition2Value"] = e.Condition2Value;
modalCondition2.Hide();
DoContinue(sender);
}
protected void btnContinue_ServerClick(object sender, EventArgs e)
{
DoContinue(sender);
}
protected void DoContinue(object sender)
{
// test for conditions - just plug to true for demonstration
bool throwCondition1 !(ViewState["Condition1Yes"] == null ? false : (bool)ViewState["Condition1Yes"])
bool throwCondition2 = !(ViewState["Condition2Yes"] == null ? false : (bool)ViewState["Condition2Yes"])
// analyze conditions
if (throwCondition1)
{
var condition1Yes = ViewState["Condition1Yes"] == null ? false : (bool)ViewState["Condition1Yes"];
if (!condition1Yes)
{
divCondition1.Visible = true;
modalCondition1.Show();
return;
}
}
if (throwCondition2)
{
var condition2Yes = ViewState["Condition2Yes"] == null ? false : (bool)ViewState["Condition2Yes"];
if (!condition2Yes)
{
divCondition2.Visible = true;
modalCondition1.Show();
return;
}
}
// do other work
}
}
Condition1UI.ascx - Condition2UI.ascx is very similar:
<%# Control Language="C#" AutoEventWireup="true" Inherits="Condition1Control" %>
<div id="divCondition1Container" runat="server">
<input id="hdnCondition1Value" type="hidden" runat="server" value="<%# this.Condition1Value %>" />
<asp:Panel ID="pnlCondition1UI" runat="server">
<br />
<h2>
Warning!</h2>
<hr />
<br />
<div>
<p>Condition1 has been met.</p>
<br />
<br />
<p>Would you like to continue?</p>
</div>
<br />
<br />
</asp:Panel>
<div>
<table>
<tr>
<td align="center">
<asp:Button ID="btnCondition1Yes" runat="server" class="green" Text="Yes" style="padding: 3px 7px;" OnClick="DoCondition1YesClick" OnClientClick="$find('dlgCondition1').hide();" />
</td>
<td align="center">
<button id="btnCondition1No" class="red">No</button>
</td>
</tr>
</table>
<br />
</div>
<br />
</div>
Condition1Control.cs - Condition2Control.cs is almost identical:
public class Condition1EventArgs : EventArgs
{
public string Condition1Value { get; set; }
}
public class Condition1Control : System.Web.UI.UserControl
{
public HtmlInputHidden Condition1Value;
public event EventHandler<Condition1EventArgs> Condition1RaisedEvent;
protected virtual void RaiseCondition1Event(Condition1EventArgs e)
{
EventHandler<Condition1EventArgs> handler = Condition1RaisedEvent;
if (handler == null)
{
return;
}
handler(this, e);
}
public void DoCondition1ButtonYesClick(object sender, EventArgs e)
{
RaiseCondition1Event(new Condition1EventArgs{
Condition1Value = Condition1Value.Value
});
}
}
Change UpdatePanel's UpdateMode property to "Always" or don't forget to call 'Update' method of UpdatePanel which UI you want to update as result of postback fired from another UpdatePanel. So try to add updateCondition2.Update method call after modalCondition2.Show method in your code.

ASP.NET updatepanel + invalid postback

I have the following very simple form:
<asp:UpdatePanel ID="ClaimRewardsForm" runat="server">
<ContentTemplate>
<span class="largeBold">Select jacket weight:</span><br />
<asp:RadioButtonList runat="server" ID="JacketWeight">
<asp:ListItem Value="Lightweight" Text="Lightweight (fleece)" />
<asp:ListItem value="Heavyweight" Text="Heavyweight (cotton)" />
</asp:RadioButtonList>
<br />
<span class="largeBold">Select size:</span><br />
(Men's sizes only)<br />
<asp:DropDownList ID="JacketSize" runat="server">
<asp:ListItem Value="Small" Text="Small" />
<asp:ListItem Value="Medium" Text="Medium" />
<asp:ListItem Value="Large" Text="Large" />
</asp:DropDownList><br />
<br />
<asp:ImageButton ID="SubmitButton" runat="server" ImageUrl = "~/Content/Images/submitButton.png" onclick="SubmitButton_Click" />
</ContentTemplate>
</asp:UpdatePanel>
In my button's click handler, I have:
protected void SubmitButton_Click(object sender, EventArgs e)
{
if (IsValid)
{
using (var work = UnitOfWorkFactory.Create())
{
var id = new Guid(Session["id"].ToString());
var account = UserAccounts.Get(id);
if (account == null)
throw new Exception("Invalid user account id.");
account.RewardInfo.Clear();
account.RewardInfo.Add(new RewardInfo()
{
UserAccount = account,
JacketWeight = JacketWeight.SelectedValue,
JacketSize = JacketSize.SelectedValue
});
work.Commit();
}
//ClaimRewardsForm.Update();
//ScriptManager.RegisterStartupScript(this, GetType(),
// "confirmation", "ClaimRewards.showConfirmation();", true);
}
}
I'm not modifying the form fields in any way whatsoever, but I'm still getting the following error:
505|error|500|Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%# Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.|
Since I'm not modifying teh controls at all during the post back, I cannot for the life of me figure out why it's acting as if I had. Any thoughts?
This guy here is your culprit. You'll have to figure out what you are posting to cause it to block the request or disable EventValidation if you understand the security risks.
I don't see anything in your posted code but <> in option values messes with it for sure.
Stupid me. I'm using a DropDownList adapter to allow for optiongroup elements within my list but that was causing an invalid postback because it modifies the elements in the list behind the scenes without registering the modified values for event validation. I modified the adapter to perform the registration and it works fine now.

ModalPopupExtender and validation problems

The problem I am facing is that when there is validation on a page and I am trying to display a model pop-up, the pop-up is not getting displayed. And by using fire-bug I have noticed that an error is being thrown.
The button that is used to display the pop-up has cause validation set to false so I am stuck as to what is causing the error.
I have created a sample page to isolate the problem that I am having, any help would be greatly appreciated.
The Error
function () {Array.remove(Page_ValidationSummaries, document.getElementById("ValidationSummary1"));}(function () {var fn = function () {AjaxControlToolkit.ModalPopupBehavior.invokeViaServer("mpeSelectClient", true);Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);}) is not a function
http://localhost:1131/WebForm1.aspx
Line 136
ASP
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CLIck10.WebForm1" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Button ID="btnPush" runat="server" Text="Push" CausesValidation="false" onclick="btnPush_Click" />
<asp:TextBox ID="txtVal" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtVal" ErrorMessage="RequiredFieldValidator" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server">
<asp:UpdatePanel ID="upnlSelectClient" runat="server">
<ContentTemplate>
<asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<input id="popupDummy" runat="server" style="display:none" />
<ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server"
TargetControlID="popupDummy"
PopupControlID="pnlSelectClient"
OkControlID="popupDummy"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancel"
DropShadow="true" />
</div>
</form>
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CLIck10
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOK_Click(object sender, EventArgs e)
{
mpeSelectClient.Hide();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
mpeSelectClient.Hide();
}
protected void btnPush_Click(object sender, EventArgs e)
{
mpeSelectClient.Show();
}
}
}
This is an issue with using both ValidationSummary and ModalPopup.
see here: http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=12835
The problem is that there is a missing ";" between the two injected scripts.
Their solution is to create/use a custom server control that inherits from ValidationSummary, that injects a ";" into the page startup script to fix the bug:
[ToolboxData("")]
public class AjaxValidationSummary : ValidationSummary
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), this.ClientID, ";", true);
}
}
Try setting your ValidationSummary "Enabled" property to false on this event : "btnPush_Click"
; and then setting it back to enabled = "true" on this events : "btnOK_Click" ,"btnCancel_Click".
I think this will work if you do not have the validation summary inside the Panel that you want to pop up.But it is not a solution if you need the validation summary inside the pop up panel,...witch is my case :(.
Best Regards.
I tried all the available answer online but didn't worked any. Then i tried to move my modal popup extender at very end of the HTML and it works fine for me. Me and my users are Happy :)
I am not using FROM tag I am using Content place holder just like below:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<table id="tblMessage" runat="server" width="100%" >
<tr align="center">
<td align="center">
main content and
<asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:UpdatePanel ID="upnlSelectClient" runat="server">
<ContentTemplate>
<asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
If you notice i have validation summary inside the panel because i want error message inside the pop up(i have some additional control in pop up too). and
Some more HTML tag here as i have so many other things to do in one page. right before closing tag of TABLE
<ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server"
TargetControlID="popupDummy"
PopupControlID="pnlSelectClient"
OkControlID="popupDummy"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancel"
DropShadow="true" />
</table>
Done.it's working. Hope that works for other too.
Are you using validation groups anywhere on the page? I've had problems with control events not firing when they are not part of a validation group and other controls on the page are part of a validation group.
I'd try changing this:
<input id="popupDummy" runat="server" style="display:none" />
to something like this:
<asp:Button id="popupDummy" runat="server" CausesValidation="false" Visible="false" />
I bet the untyped input is requiring validation.
i had the same issue, adding ValidationGroup to the validation controls did the trick!
One other thing to try, if you don't need Client Script you can disable it in the markup. Doing that fixed our problem.
EnableClientScript="false"

How to bind a nested control from main page code behind

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="&nbsp" />
<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();
}
}
}
You shouldn't be exposing the internals of CustomControl1 to a consumer, so the most correct way would be to expose a public method (maybe call it "ResetDropDowns") on your CustomControl1 that the main page could call into.
CustomControl1 knows about it's own dropdowns, so it can easily find and rebind the control when someone calls the method.
Ok, we have a solution thanks to "womp's" suggestions and one of my co-workers.
Just keep nesting the public calls in a chain:
This in the main Claim Info code behind:
// Rebind the action code drop down to restrict to base level
mailAddSubform.BindMailActionLookup();
Then this in the subform code behind:
public void BindMailActionLookup()
{
mailActionLookup.BindMailActionLookup();
}
And finally, this in the lookup control:
public void BindMailActionLookup()
{
BindForm();
}

Resources