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

RadControls Sharepoint

3 Answers 52 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Amahde
Top achievements
Rank 1
Amahde asked on 15 Sep 2008, 09:43 PM

I am trying to edit connected webpart to use the RadMager/Radpanel instead on an ajax update panel are there any C# examples, on this implimentation.

private void SetupSharePointAjax()

{

this._hostPanel = new UpdatePanel();

this._hostPanel.ID = AJAXCommon.AJAX_HOSTPANEL_NAME + this.ClientID;

this._hostPanel.UpdateMode = UpdatePanelUpdateMode.Conditional;

this._hostPanel.ChildrenAsTriggers = true;

this.Controls.Add(_hostPanel);

if (this.Page.Form != null)

{

ScriptManager.RegisterStartupScript(

this, typeof(ClientsWebPart),

AJAXCommon.SHAREPOINT_AJAX_POSTBACK_SCRIPTNAME,

AJAXCommon.SHAREPOINT_AJAX_POSTBACK_SCRIPT,

true);

private

void CreateGrid()

{

_gridView.Columns.Clear();

AddColumnsToGrid();

this._scriptManager = ScriptManager.GetCurrent(this.Page);

if (_scriptManager == null) // Add a script manager

{

this._scriptManager = new ScriptManager();

this._scriptManager.EnablePartialRendering = true; // needed for Update Panel to work

this._scriptManager.EnableScriptLocalization = true;

this.Controls.AddAt(0, this._scriptManager); // Script Manager should be the first control on the form

}

this.SetupSharePointAjax();


 

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 16 Sep 2008, 08:31 AM
Hello Amahde,

Basically, you can incorporate RadAjaxPanels in your Sharepoint webpart in the same way as you will do that with regular MS UpdatePanels. There is one detail which you need to have in mind when using RadAjaxManager inside your web part - it is explained in this section of the product documentation.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Amahde
Top achievements
Rank 1
answered on 16 Sep 2008, 04:03 PM
Thank you for your reply, is it posible to get something a little more specific.  Is there more information avilible or any specific examples I can leverage.below

I get the error below:

The control with ID 'radPanel1' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
Description: An

private void SetupSharePointAjax()
        {
            this._radPanel = new RadAjaxPanel();
            this._radPanel.ID = "radPanel1";
            this.Controls.Add(_radPanel);

            if (this.Page.Form != null)
            {
                ScriptManager.RegisterStartupScript(this, typeof(ClientsWebPart),
                    AJAXCommon.SHAREPOINT_AJAX_POSTBACK_SCRIPTNAME,
                    AJAXCommon.SHAREPOINT_AJAX_POSTBACK_SCRIPT, true);
            }
        }
        [ConnectionProvider("contactId")]
        public IContactProvider GetContactIdProvider()
        {
            return this;
        }

        public string ContactId
        {
            get { return _contactId; }
        }

        public string ContactDisplayName
        {
            get { return _contactDisplayName; }
        }

        protected override void OnInit(EventArgs e)
        {
            _gridView = new GridView();

            SetXml();
            //Controls.Add(_gridView);
            base.OnInit(e);

        }

        protected override void OnPreRender(EventArgs e)
        {
            EnsureChildControls();
            //this._hostPanel.ContentTemplateContainer.Controls.Add(_gridView);
            //((UpdatePanel)Controls[Controls.IndexOf(this._hostPanel)]).ContentTemplateContainer.Controls.Add(_gridView);
            SetXml();
            SetSelectedRow();
            base.OnPreRender(e);
        }

        private void SetXml()
        {
            Connection conn = new Connection(ConfigurationSettings.AppSettings["IAAPIServerPath"]);
            conn.Authenticate(ConfigurationSettings.AppSettings["IAAPIAccountName"], "p");
            IAAppServerManager mgr = new IAAppServerManager(conn);
            IAAppServerRequest req = new IAAppServerRequest("findClients");
            req.SetParameter("isClient", "true");
            IAAppServerResponse resp = mgr.Execute(req);

            if (resp.ErrorCode != 0)
            {
                // an error occured on the app server
            }
            else if (resp.XmlString == null)
            {
                // we didn't get any xml?
            }
            else if (resp.ResultCount == 0)
            {
                // no results found
                _gridView.DataSourceID = "";
                _gridView.DataBind();
            }
            else
            {
                XmlReader xr = XmlReader.Create(new StringReader(resp.XmlString));
                _xmlData = new DataSet("IA XML");
                _xmlData.ReadXml(xr, XmlReadMode.Auto);
            }
        }

        // Reestablish the selected row if another web part caused page to refresh
        private void SetSelectedRow()
        {
            if (ViewState["selectedIndex"] != null)
            {
                _gridView.SelectedIndex = (int)ViewState["selectedIndex"];
                _contactId = _gridView.Rows[_gridView.SelectedIndex].Cells[0].Text;
                ViewState["contactId"] = _contactId;
                _contactDisplayName = _gridView.Rows[_gridView.SelectedIndex].Cells[3].Text;
            }
        }

        protected override void CreateChildControls()
        {

            CreateGrid();
            base.CreateChildControls();
        }

        private void CreateGrid()
        {
            _gridView.Columns.Clear();

            AddColumnsToGrid();

            //this._scriptManager = ScriptManager.GetCurrent(this.Page);
            //if (_scriptManager == null) // Add a script manager
            //{
            //    this._scriptManager = new ScriptManager();
            //    this._scriptManager.EnablePartialRendering = true; // needed for Update Panel to work
            //    this._scriptManager.EnableScriptLocalization = true;
            //    this.Controls.AddAt(0, this._scriptManager); // Script Manager should be the first control on the form
            //}

            this._scriptManager = ScriptManager.GetCurrent(this.Page);
            if (_scriptManager == null) // Add a script manager
            {
                this._radjaxManager = new RadAjaxManager();

                this.Controls.AddAt(0, this._scriptManager); // Script Manager should be the first control on the form
            }

            this.SetupSharePointAjax();

0
Sebastian
Telerik team
answered on 17 Sep 2008, 07:29 AM
Hello Amahde,

Based on the exception stack trace, I think that the ScriptManager instance is not positioned as first control in the form and this is the reason for the error. Can you try replacing this line of code:

this.Controls.AddAt(0, this._scriptManager); // Script Manager should be the first control on the form

with this one:

this.Page.Form.Controls.AddAt(0, this._scriptManager); // Script Manager should be the first control on the form

to see whether this helps? You may also debug your code and examine the Controls collection of the page to determine the position of the ScriptManager control in it.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
Amahde
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Amahde
Top achievements
Rank 1
Share this question
or