I have an ASP.NET web form making an ajax request to a service which returns some html to inject into the page. The service dynamically renders a usercontrol to a string which is the html returned. In the usercontrol we have a WebDateChooser. The WebDateChooser is rendering just fine, but none of the client side events are firing to display the calendar. The same thing is happening for the WebDateTimeEdit control as well. Below is a snippet we use to render the usercontrol to a string, which gets returned to the client and injected into the page:
Page pageHolder = new Page(); UserControl viewControl = pageHolder.LoadControl("~/path/to/control.ascx") as UserControl; pageHolder.Controls.Add(viewControl); StringWriter output = new StringWriter(); HttpContext.Current.Server.Execute(pageHolder, output, false); return output.ToString();
When i put a WebDateChooser right into a normal page i see a bunch of WebResource.axd requests which pull in necessary js for the control. I'm not seeing this with the dynamic rendering we are doing, but I don't know how to force these scripts to load(or manually load them myself). Any help is appreciated.
Kyle
Hi Kyle,
That is correct. All Infragistics controls depend on js files and initialization scripts which create controls. In case of Infragistics.WebUI controls like WebDateChooser, it is rather easy to use local js files. Custom location of js files can be modified on global level within webconfig file or for every particular control. In second case, the only requirement is that location of ig_shared.js file should be the same for all controls on page.WebDateChooser uses 3 js files: ig_webdropdown.js, ig_calendar.js and ig_shared.js. Those js files and js files for other controls come with installation of NetAdvantage.Below is example to set local js files for WebDateChooser:
<igsch:WebDateChooser ID="WebDateChooser1" runat="server" CalendarJavaScriptFileName="./js/ig_calendar.js" JavaScriptFileName="./js/ig_webdropdown.js" JavaScriptFileNameCommon="./js/ig_shared.js"></igsch:WebDateChooser>
However, if a page, where html string for webdatechooser with its init-javascript are inserted, will have those js file loaded, then control should work and no need to adjust any settings, which I mentioned above.
Hi,
I am trying to render a WebDateChooser dynamically. The control is rendered through HTMLWriter and is bound to Repeater control. The problem is this just paints the control and no server or client side events are happening.
I have gone through the solutions provided in forum and it says the control needs a container control to work. I tried adding the control to dynamically generated DIV , but still this issue persists.
I have created a UserControl which has the WebDateChooser and i am trying to load that user control inside the DIV. But this also does not work.
I also created HTMLForm object and tried to render the control through form but with no luck.
Can you please tell me how can i make this control initialize?
Code Sample:
writer.RenderBeginTag(HtmlTextWriterTag.Td) Dim p As Page = CType(HttpContext.Current.Handler, Page) Dim c As Control = p.LoadControl("DynamicWebDateChooser.ascx") c.RenderControl(writer) writer.RenderEndTag()
The output returned from the function is bound to repeater control.