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

[Solved] Ajax Manager Prometheus - Client-side

3 Answers 365 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
willie
Top achievements
Rank 1
willie asked on 13 Aug 2007, 10:30 AM
Hello,

I have a Menu. I am able to drag and drop a menu item to the content area of the master page. On the drop of the menu item I make a client-side Ajax Request to the server. The request goes successfully.

On the server-side in the AjaxManager_AjaxRequest event, I render a few controls at runtime. Unfortunately, all the code executes successfully but, nothing is rendered in the content area.

I have tried adding the Ajax Settings using code as I am using a User Control at runtime.   Please help!!

Regards,
William

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Aug 2007, 10:40 AM
Hello William,

We are afraid that we do not understand completely the problem you are experiencing. Creating controls in the AjaxRequest event handler is equal to creating controls on postback request from any control on the page, meaning that the newly created control will have to be recreated on Page_Load in order for it to exist on subsequent requests. If we have misunderstood your problem, please provide more info or a sample code and we will gladly advise you.

Regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
willie
Top achievements
Rank 1
answered on 13 Aug 2007, 11:48 AM
Thank you Steve,

On my Master Page I have created an AJAX call using below code:
Here newControl is set from a JavaScript file code and is populated based on the control that has been dragged from the right menu.

function fnCreateControl()
{       
    var hdnControl ='';
    boolCreateControl = false;       
   <%=MSMasterAJAXManager.ClientID%>.AjaxRequest(newControl);
}


Above code successfully makes a server-side call. In the AjaxManager_AjaxRequest method as below:

protected void MSMasterAJAXManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        string strPageViewCntr = null;
        if (Session["PageView"] == null)
        {
           strPageViewCntr = "0";
        }
        else
        {
            strPageViewCntr = Convert.ToString(Session["PageView"]);
        }
        RadMultiPage tabMultiPage = new RadMultiPage();
        tabMultiPage = (RadMultiPage)ctrlTabContent.FindControl("tabMultiPage");
        tabMultiPage.Visible = true;
        PageView pgView = new PageView();
        pgView.ID = "PageView" + strPageViewCntr;
        pgView.Height = Unit.Percentage(100);
        pgView.Width = Unit.Percentage(100);
        tabMultiPage.PageViews.Add(pgView);
        tabMultiPage.PageViews[Convert.ToInt32(strPageViewCntr)].Selected = true;
        tabMultiPage.PageViews[Convert.ToInt32(strPageViewCntr)].Visible = true;
        RadDockLayout dcl_Main = new RadDockLayout();
        dcl_Main.ID = "dcl_Main";
        RadDockZone dcz_Main = new RadDockZone();
        dcz_Main.ID = "dcz_Main";
        dcz_Main.BorderColor = Color.Black;
        dcz_Main.BorderStyle = BorderStyle.Dotted;
        dcz_Main.BorderWidth = Unit.Pixel(1);
        Session["PageView"] = Convert.ToString(Convert.ToInt32(strPageViewCntr) + 1);
}

Here I am adding PageViews dynamically with a layout, zone and then a dock.

I do not get any rendering.

Code for Page_Load:
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
        {          
            pnlCoreContent = (Panel)cntPlaceHolder.FindControl("cntCorePanel");
            //Calling it after getting the handle of the CorePanel;
            SetMasterPageHeader();
            strContentArea = pnlCoreContent.ClientID;
            pnlRightMenu.Visible = true;
            ctrlTabContent = Page.LoadControl("UserControls/TabPages.ascx");
            ctrlTabContent.ID = "tabMultiPage";
            pnlCoreContent.Controls.Add(ctrlTabContent);
MSMasterAJAXManager.AjaxSettings.AddAjaxSetting(MSMasterAJAXManager,ctrlTabContent.FindControl("tabMultiPage"));
            if (!Page.IsPostBack)
            {
                Session["PageNumber"] = "1";
                Session["PageIndex"] = "0";
                Session["LayoutCnt"] = null;
                RadTabStrip1.SelectedIndex = 0;
            }
        }
        catch (Exception ex)
        {
            string strex = ex.Message.ToString();
        }
    }

Thanks and Regards,
William

0
Yavor
Telerik team
answered on 15 Aug 2007, 02:57 PM
Hello willie,

I reviewed the code. Please, keep in mind, as noted previously by Steve, that creating the control in ana Ajax request is not the appropriate approach. Additionally, in order to render and Ajaxify the controls, you will need to add them properly to the settings of the AjaxManager. Additionally, you can use a panel, in which to nest the controls, and then include this panel to be ajaxified by the manager.
I hope these directions are helpful.

Best wishes,
Yavor
the Telerik team

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