Rendering Telerik Radmenu as HTML

7 posts, 0 answers
  1. Shailesh
    Shailesh avatar
    6 posts
    Member since:
    Jul 2008

    Posted 21 May 2011 Link to this post

    Hi,

    Requirement:
    As per requirement, I have written a Asp.Net Web Service that would process a user control (written using base class as System.Web.UI.UserControl) and return pure HTML as string. This user control contains Telerik RadMenu that has several menu items. Here is the code from web service for processing user control and returning the HTML.

    [WebMethod]
            public string RenderView()
            {
                try
                {
                    Page page = new Page();
                    WebUserControl1 ctl = (WebUserControl1)(page.LoadControl("/WebUserControl1.ascx"));
                    page.EnableEventValidation = false;
                    HtmlForm _form = new HtmlForm();

                    page.Controls.Add(_form);
                    _form.Controls.Add(ctl);
                   
                    StringWriter writer = new StringWriter();
                    HttpContext.Current.Server.Execute(page, writer, false);
                    String output = writer.ToString();
                    writer.Close();

                    return output.ToString();

                }
                catch (Exception e)
                {
                    string error = e.ToString();
                    return error;
                }
            }

     

    Then I am consuming this web service from some other Asp .Net web application. In that web application, I have one aspx page with usual data on it. Also it has a literal control inside <div> tag at some place. I am rendering the returned HTML in literal control and expecting the Telerik Radmenu to work.

    Problem:
    Telerik Radmenu refers several css and js files which are served as webresource from Telerik assembly. In above implementation, the rendered HTML output does contain webresource reference. However since the web application (that is consuming the web service) is different and user control/web service together are residing in different web application, the Telerik Radmenu is not working as expected i.e. it does not expand/collapse.

    Questions:
    Rather than referencing css and js files through webresource, Is it possible to give reference to both css and js files through simple <link> tag? So that those files could be referenced (via <Link> tag with source as URL) in other web application (that is consuming the web service)?

    Thanks,
    Shailesh

  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 26 May 2011 Link to this post

    Hi Shailesh,

    I am not sure that I understand what you mean by “other web application”.
    Is the application that calls the web service method internal to your project?
    Are both – web service and application placed within the same solution?
    Do you develop this application?

    In case you expose the RadMenu rendered html to be consumed from applications that are external to your project - this breaks our license agreement.

    Why have you decided to implement such scenario?
    In fact you can easily populate the RadMenu with data via Web Services as is demonstrated here instead of returning the rendered html as a string result of web method call.

    Best wishes,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Shailesh
    Shailesh avatar
    6 posts
    Member since:
    Jul 2008

    Posted 28 May 2011 Link to this post

    Hi,

    Thanks for the reply. Please find my comments/queries inline in bold.

    I am not sure that I understand what you mean by “other web application”.
    Is the application that calls the web service method internal to your project?
    Are both – web service and application placed within the same solution?
    Do you develop this application?
     --> No, this other web application is a third party web application and so it is not within same solution.

    In case you expose the RadMenu rendered html to be consumed from applications that are external to your project - this breaks our license agreement.

    Why have you decided to implement such scenario?
    --> In header section of our web application, we have implemented site navigation using RadMenu. This third party web site needs to show our site's header section in one of their page. Initially we were trying to implement this by means of hosting an iFrame in their page and then that iFrame will link to a page in our web application and that will show the header. However, the issue in this scenario is that, on mouse over of navigation, the expanded menu section was getting cut due to iFrame height. And due UI limitations, we cannot increase the height of iFrame. Also use of z-index did not help us to bring the expanded menu out of iFrame and overlap in their page. That’s the reason we thought of exposing HTML via web service which third party web application could consume. If this is going break the license agreement then please let me know if you have any better alternative.

    In fact you can easily populate the RadMenu with data via Web Services as is demonstrated here instead of returning the rendered html as a string result of web method call.

    Best wishes,
    Kalina
    the Telerik team
  4. Shailesh
    Shailesh avatar
    6 posts
    Member since:
    Jul 2008

    Posted 28 May 2011 Link to this post

    Hi,

    I forgot to amend one more query to my earlier reply.

    --> If I purchase the Telerik controls license for our web application then still this scenario would break the license agreement? Please confirm. If the third party web application also purchases the license for Telerik controls then would it still break the agreement?
  5. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 02 Jun 2011 Link to this post

    Hello Shailesh,

    Yes there is a conflict with our license agreement if you continue using the scenario that you describe - exposing the RadMenu as a result or web service to third-party applications.
     
    Additionally – please note that our controls are not designed to be passed as a result of web service calls.
    So you will be not able to provide a working control anyway.

    The best solution for your case is to use iframe. Simply increase iframe height in order to enable expanded menu sections fit in the area.  Another approach that you can follow is to use the RadMenu Scrolling.

    All the best,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Shailesh
    Shailesh avatar
    6 posts
    Member since:
    Jul 2008

    Posted 08 Jun 2011 Link to this post

    Hi,

    Thanks for your reply and apologize for bothering again. Actually around licensing I had asked one more query in last post.

    So I just want to re-confirm the same, i.e. if I purchase the Telerik controls license and the third party (that would consume the web service) purchases the Telerik controls license too then would it still violate the license agreement?

    By the way, another query on your reply "Additionally - please note that our controls are not designed to be passed as a result of web service calls. So you will be not able to provide a working control anyway."
    Basically I am not going to set return type for web service method as Telerik control itself. Web service method is just going to return pure html string. The reference to Telerik scripts (js/css) would already be part of that html. And these Telerik scripts (js/css) would be hosted in my web application site (not through script reference). I already tried this approach locally and it worked fine. Do you feel it is still not going to work?

    Thanks,
    Shailesh 

  7. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 10 Jun 2011 Link to this post

    Hello Shailesh,

    I suppose that I haven’t been clear enough in my previous answer.
    When you return a RadMenu as a result of a web method - even as a string - it will not work, because simply it is not designed to work in this scenario.
    Regarding your question about the licensing agreement - please take a look at the answer of the support ticket that you have opened.

    Regards,
    Kalina
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top