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

[Solved] Client Callback to return Html + JS for new Telerik Control

4 Answers 266 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matt Middlesworth
Top achievements
Rank 2
Matt Middlesworth asked on 18 Sep 2009, 06:40 PM
I'm running clientside Callbacks for performance reasons and I would like to Add new elements to the display in the form of HTML/JS and load new Telerik Web Controls as certain selections are processed. The code below samples what I would like to do.

public void RaiseCallbackEvent(String eventArgument)
{
TextWriter text = new StringWriter();
HtmlTextWriter html = new HtmlTextWriter(text);

RadComboBox comboBox = new RadComboBox();
comboBox.ID = "test";
comboBox.RenderControl(html);
html.Flush();

callBackReturn = text.ToString();
}

public String GetCallbackResult()
    {
        return callBackReturn;
    }

The Error i Receive is on comboBox.RenderControl(html) line : Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.

Can you dynamically create new Telerik controls using ClientSide Callbacks? Will this be something that will be supported in the future?

Thanks,

Matt

4 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 23 Sep 2009, 11:30 AM
Hello,

Rendering ASP.NET AJAX controls separately is hard in general. Obtaining the actual HTML is probably the easiest part here. You'll also have to register the control client-side scripts and skins, either manually or during the update. You'll then have to generate a $create statement to instantiate the client-side object of the control. This is really a lot of work and will not be trivial to implement from scratch.

We have a solution to this problem - RadXmlHttpPanel. It does all the dirty job needed to properly render the controls while still using a lightweight callback or web service request. It's not a replacement for the standard UpdatePanel or for RadAjaxUpdatePanel, but only aims to complement them for scenarios where simple and fast partial updates are needed.

I've attached a sample project that you can try. There's one caveat though - you have to use the latest internal build of the controls for it to work. I've included the trial assemblies in the project for your convenience.

And something else - controls rendered in the RadXmlHttpPanel can't fire server events, so you'll have to use their client-side API to implement your business logic.

I hope this helps.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matt Middlesworth
Top achievements
Rank 2
answered on 24 Sep 2009, 12:23 AM
Thanks,

I will see if this implementation will work for my needs.

Matt
0
Craig Riter
Top achievements
Rank 1
answered on 10 Feb 2010, 08:27 PM
Tsvetomir

Does this still require an internal build?

Can you be a little more descriptive on this statement?

You'll then have to generate a $create statement to instantiate the client-side object of the control. This is really a lot of work and will not be trivial to implement from scratch.


Craig
0
T. Tsonev
Telerik team
answered on 15 Feb 2010, 12:43 PM
Hello Craig,

No, you don't need internal build for this functionality. We have a demo here:

http://demos.telerik.com/aspnet-ajax/xmlhttppanel/examples/windowinxmlhttppanel/defaultcs.aspx

As you can see, the $create script is handled automatically by RadXmlHttpPanel.

Best wishes,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Matt Middlesworth
Top achievements
Rank 2
Answers by
T. Tsonev
Telerik team
Matt Middlesworth
Top achievements
Rank 2
Craig Riter
Top achievements
Rank 1
Share this question
or