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

How to update a control in one ASCX page from another ASCX page ?

1 Answer 218 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Reunisoft
Top achievements
Rank 1
Reunisoft asked on 02 Apr 2009, 12:03 PM
Greetings.

I have coded an ASP.NET application such as follow :

Default.aspx
    MainPage.ascx
        RadTabStrip
            FirstTab.ascx
            SecondTab.ascx
            ThirdTab.ascx

On SecondTab.ascx, there is a checkbox. When this is checked, I want to update a dropdownlist that is on MainPage.ascx

Do you see how I could do that with RadAjaxManager that has been added on SecondTab.ascx ?

Thanks !!!!

1 Answer, 1 is accepted

Sort by
0
Reunisoft
Top achievements
Rank 1
answered on 03 Apr 2009, 05:51 AM
Greetings,

As I found the solution alone :) I post it :

On SecondTab.ascx.cs, add in Page_Load :
ddl_dropdownlist.Attributes.Add("OnChange", "ajaxRequest('ddl_dropdownlist_index_changed');");
//A change in dropdownlist on SecondTab.ascx will provoke a change in another dropdownlist on MainPage.ascx

On SecondTab.ascx.cs, add a public method :
        public void myRadAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
           if (e.Argument != null)
            {
                if (e.Argument == "ddl_dropdownlist_index_changed")
                {
                    try
                    {
                        DropDownList ddldestination = (DropDownList)Parent.FindControl("ddl_destination");
                        ddldestination.Items.Add(new ListItem("New Item Added","ItemValue1"));
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }

On MainPage.ascx, add :
<script type="text/javascript">
        function ajaxRequest(param)
        {
            <%=myRadAjaxManager.ClientID %>.AjaxRequest(param);
        }
</script>

On MainPage.ascx, add :
<radA:RadAjaxManager ID="myRadAjaxManager" runat="server" EnableAJAX="true" OnAjaxRequest="myRadAjaxManager_AjaxRequest">
    <AjaxSettings>
        <radA:AjaxSetting AjaxControlID="ddl_dropdownlist">
            <UpdatedControls>
                <radA:AjaxUpdatedControl ControlID="ddl_destination" />
            </UpdatedControls>
        </radA:AjaxSetting>
</radA:RadAjaxManager>





Tags
Ajax
Asked by
Reunisoft
Top achievements
Rank 1
Answers by
Reunisoft
Top achievements
Rank 1
Share this question
or