This is a migrated thread and some comments may be shown as answers.

[Solved] how to apply ajax on dynamically added usercontrol

8 Answers 295 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
saqib
Top achievements
Rank 1
saqib asked on 20 Mar 2008, 02:25 PM

In my project i am adding usercontrol dynamically that is productlist.ascx in content page which is LoadPage.aspx (using master page). there are two dropdown on productlist.ascx: one is drpcountry and other is drpcity. i am filling drpcity when i click on drpcountry using ajax. But ajax is not applying in this scenerio on dropdown click.

But in other case where usercontrol is static in aspx page is working fine. In above case when it is dynamic it is not working.

Code on ProductList.ascx:

<asp:DropDownList ID="drpCountry" runat="server" Width="148px" AutoPostBack="True" OnSelectedIndexChanged="drpCountry_SelectedIndexChanged" meta:resourcekey="drpCountryResource1" >
        </asp:DropDownList>
<asp:DropDownList ID="drpCity" runat="server" Width="148px" meta:resourcekey="drpCityResource1">
            <asp:ListItem Value="0" meta:resourcekey="ListItemResource1">-- Not Available --</asp:ListItem>
        </asp:DropDownList>

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="drpCountry">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="drpCity" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

 

code on LoadPage.aspx:

<asp:Content ID="content1" ContentPlaceHolderID="CentralColumn" runat="server">
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
     </telerik:RadScriptManager>
 <asp:Panel ID="Panel1" runat="server" Height="50px" Width="100%">
    </asp:Panel>
 <asp:PlaceHolder ID="phControlHolder" Runat="server" Visible="True"></asp:PlaceHolder>
    &nbsp;<br />
    <radA:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="100%">
        &nbsp;
        &nbsp;&nbsp;
       
    </radA:RadAjaxPanel>

  
        <radA:RadAjaxManager ID="RadAjaxManager2" runat="server">
        </radA:RadAjaxManager>
        <radA:AjaxLoadingPanel ID="AjaxLoadingPanel2" runat="server" Height="75px" Width="75px">
            <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/App_Themes/Ajax/Default/loading.gif" />
        </radA:AjaxLoadingPanel>
  

</asp:Content>

i am dynamically adding usercontrol in panel on loadpage.aspx page.

i am currently using new radcontrols "RadControls_Prometheus_2007_3_1425".

8 Answers, 1 is accepted

Sort by
0
Leon
Top achievements
Rank 1
answered on 21 Mar 2008, 06:57 AM
Saqib,

Does that mean you use both the old and Prometheus RadAjax at the same time? Try a single RadAjaxManager from the Telerik.Web.UI package and RadAjaxManagerProxy in addition where needed. Adding RadAjaxPanel in a complex scenario (MasterPage/UserControls) is also not recommended. Here is a helpful resource you can review:

http://www.telerik.com/help/radcontrols/prometheus/ajxAjaxMasterPage.html

Thanks!
-Leon
0
saqib
Top achievements
Rank 1
answered on 25 Mar 2008, 12:05 PM

i chnage my code according to your instruction but there is no effect on ajax on usercontrol that i am adding to content page dynamically

Code on ProductList.ascx:

<asp:DropDownList ID="drpCountry" runat="server" Width="148px" AutoPostBack="True" OnSelectedIndexChanged="drpCountry_SelectedIndexChanged" meta:resourcekey="drpCountryResource1" >
        </asp:DropDownList>
<asp:DropDownList ID="drpCity" runat="server" Width="148px" meta:resourcekey="drpCityResource1">
            <asp:ListItem Value="0" meta:resourcekey="ListItemResource1">-- Not Available --</asp:ListItem>
        </asp:DropDownList>

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="drpCountry">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="drpCity" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

 

code on LoadPage.aspx:

<asp:Content ID="content1" ContentPlaceHolderID="CentralColumn" runat="server">
     <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
     </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">
        </telerik:RadAjaxManager>
       
 <asp:Panel ID="Panel1" runat="server" Height="50px" Width="100%">
    </asp:Panel>
 <asp:PlaceHolder ID="phControlHolder" Runat="server" Visible="True"></asp:PlaceHolder>
    &nbsp;<br />
      

</asp:Content>

i am dynamically adding usercontrol in panel on loadpage.aspx page.

i am currently using new radcontrols "RadControls_Prometheus_2007_3_1425".


please help me because it is urgent

0
Vlad
Telerik team
answered on 25 Mar 2008, 12:11 PM
Hi saqib,

At which stage of page lifecycle these controls are added?

Regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
saqib
Top achievements
Rank 1
answered on 25 Mar 2008, 12:20 PM
i am adding usercontrol dynamically in contentpage placeholder

<asp:PlaceHolder ID="phControlHolder" Runat="server" Visible="True"></asp:PlaceHolder>


i am adding control in Page_Load evant of content page.
0
Steve
Telerik team
answered on 25 Mar 2008, 12:26 PM
Hi saqib,

asp:PlaceHolders do not render any html to the page and so does the user controls. You need a control wrapper like asp:Panel, div etc. that renders some html on the page in order to handle this with ajax. Another thing is that generally the asp:ScriptManager control is recommended to be the first control on the page. This would not be applicable when it is placed in the content page. Try placing the scriptmanager and the main RadAjaxManager in the MasterPage.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
saqib
Top achievements
Rank 1
answered on 25 Mar 2008, 12:52 PM
As according to your instruction i put scriptmanager and Radmanager in master page and also replace placeholder with panel to add control at run time.

but same as already mean no ajax call. when i click on drpcountry then there is no effect on page mean neither refresh page nor any ajax call occur for drpcity.
0
saqib
Top achievements
Rank 1
answered on 25 Mar 2008, 02:41 PM
i try my best to solve this problem but there is no solution please give me any other solution to solve this problem
0
Steve
Telerik team
answered on 27 Mar 2008, 11:28 AM
Hello saqib,

I've attached a working project following the description from your previous posts. It works as expected - please give it a spin and let us know if further help is needed.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
saqib
Top achievements
Rank 1
Answers by
Leon
Top achievements
Rank 1
saqib
Top achievements
Rank 1
Vlad
Telerik team
Steve
Telerik team
Share this question
or