I have an app that allows user to pick reports to run. Each report has its own set of parameters. When that parameter is a DateTime, I'd like to use the WebDatePicker. The controls are created in the code-behind page.
This is working with all the asp.net controls. But when I try to do it with Infragistics WebDatePicker, I get a text-box and button. Clicking the button shows a message in the status bar about "Downloading pictures from http://localhost..gte_SpinButtonbgPressed.gif" hard to see as it goes by so fast.
I have include reference to the Infragistics.Web.UI.EditorControls in the .aspx file and "using Infragistics.Web.UI.EditorControls" in the code-behind.
Here are the lines of C# code I'm using to create the controls:
ctlParam = new WebDatePicker();
pnlParametersRight.Controls.Add(ctlParam);
ctlParam.EnableViewState =
false;
ctlParam.Width = 225;
ctlParam.ID = rpi.Name;
ctlParam.Attributes.Add(
"StyleSetName", "Default");
"ChangeMonthToDateClicked", "true");
"EnableMonthDropDown", "true");
"EnableYearDropDown", "true");
Is there something I'm missing in this code?
Here's what I'm seeing in the source code for the WebDatePicker control when I run the app:
<td style='text-align:right;'>
<span class="ParameterLabel">Start Date</span>
</td>
<td style='text-align:left;'>
<input type="hidden" id="mnuiQuery_tmpl1_StartDate_clientState" name="mnuiQuery_tmpl1_StartDate_clientState" />
<table title="{0}" id="mnuiQuery_tmpl1_StartDate" StyleSetName="Default" ChangeMonthToDateClicked="true" EnableMonthDropDown="true" EnableYearDropDown="true" class="ParameterControl igte_EditWithButtons" cellspacing="0" cellpadding="0" border="0" style="width:225px;">
<tr><td class="igte_Inner" valign="top" style="height:100%;">
<input readonly="readonly" id="x:1269809462.0:mkr:3" class="ParameterControl igte_EditInContainer" type="text" style="ime-mode:disabled;float:left;height:100%;width:99.3%;text-align:NotSet;" />
<td id="x:1269809462.1:mkr:2" align="center" valign="middle" class="igte_Button igte_ButtonSize" style="height:auto;line-height:1px;font-size:1px;">
<img class="igte_ButtonImg" src="ig_res/Default/images/igte_custom.gif" alt="Custom Action" align="middle" border="0" />
</td></tr></table>
Thanks in advance,
Michell
I have more information on this issue:
If I just add the control to a page:
Page.Controls.Add(ctlParam);
I get an error that the control needs to be in a "Form".
If I add the control as such:
Page.Form.Controls.Add(ctlParam);
it works fine.
The problem lies in the fact that this Control (ctlParam) resides in an ASP.Panel, which is inside an Infragistics ContentTabItem, which is part of an Infragistics WebTab.
I know that when I need to retrieve the data from these dynamic controls, I need to get them as:
mnuiQuery.FindControl("tmpl1").FindControl("pnlParametersRight").FindControl(rpi.Name)
where mnuiQuery is the name of the Infragistic WebTab, "tmpl1" is the second tab on that control, and "pnlParametersRight" resides on that tab.
I tried going through all that as:
Page.Form.FindControl("mnuiQuery").FindControl("tmpl1").FindControl("pnlParametersRight").Controls.Add(ctlParam);
but that gives me the same unresponsive control as adding it directly to the panel ("pnlParametersRight").
Your feedbck is appreciated,
Hi Michell,
That is correct, a server control (or its container/s) should belong to Form.Controls, but not to Page.Controls. So, application should ensure that any dynamic Control does not appear outside of Form. Of in case of aspx, a control should be inside of <form>. Otherwise, that control will not function correctly on client and/or values modified on client will be not passed to server after a postback.
If WebDatePicker is created dynamically and there was no other WebDatePicker on initialization, then application may ensure loading shared WebMonthCalendar by something like below:
protected void Page_Load(object sender, EventArgs e){ Infragistics.Web.UI.EditorControls.WebDatePicker.EnsureSharedCalendar(this);}
I would expect that if WebMonthCalendar is added dynamically to the same container as WebDatePicker and its DropDownCalendarID is set to the ID/ClientID of that calendar, then WebDatePicker should find that calendar on client, hide it on initialization and show calendar on button click. If it does not work.
If container of WebDatePicker is not loaded asynchronously (Ajax is not enabled in WebTab), then you may look at generated html and check if it contains tags and javascript related to WebMonthCalendar attached to WebDatePicker. For example search and verify that html elements contain ID of calendar and those html elements appear within <form> object. Html content can be something like
<input type="hidden" id="...WebMonthCalendar1_clientState" .. /><table id="...WebMonthCalendar1"...>...Sys.Application.add_init(function() { $create(Infragistics.Web.UI.WebMonthCalendar, {"id":"...WebMonthCalendar1"...});
If ajax is enabled and container of WebDatePicker is loaded asynchrously, then you may try to debug by processing ClientSideEvents.CalendarOpening and check if WebMonthCalendar object can be found. WebDatePicker has member variable _calID, which is set to the ID of calendar and $util has member method findControl(id).
<script type="text/javascript">function WebDatePicker1_CalendarOpening(sender, eventArgs){ var calID = sender._calID; debugger; var cal = $util.findControl(calID); alert('cal:' + cal);}</script><ig:WebDatePicker ID="WebDatePicker1" runat="server" DropDownCalendarID="WebMonthCalendar1"> <ClientSideEvents CalendarOpening="WebDatePicker1_CalendarOpening" /></ig:WebDatePicker><ig:WebMonthCalendar ID="WebMonthCalendar1" runat="server"></ig:WebMonthCalendar>
If debugging will not help, then I suggest to create a simple sample, which can be used to reproduce that issue, zip it and attach within Options tab. You also may submit a report at http://ko.infragistics.com/support/ask-for-help.aspx and provide a sample.
Viktor,
Many thanks for your response. It confirmed many of my concerns regarding how I needed to walk through the various layers of controls to find the the WebDatePicker.
I discovered this morning what was causing the issue, although why it caused an issue still escapes me:
When the app is first loaded, the last report the user generated is loaded as a "default". A report is kept in the DataBase as a "NamespaceID". When I first loaded the app, I retrieve this NamespaceID and set "ViewState["NamespaceID"]" to this value.
For whatever reason, I never used that ViewState value again. Instead, I retrieved the namespace ID value from the TreeView that showed the various folders and reports to which the user has access.
When I changed the retrieval of the NamespaceID to the following:
If (ViewState["NamespaceID"] != null) namespaceID = Convert.ToInt32(ViewState["NamespaceID"].ToString())
else namespaceID = Convert.ToInt32(tvwQueries.SelectedNode.Value.ToString());
At any rate, I seem to have the issue under control.
Thanks again for taking the time to respond. Your feedback has been most helpful.