New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Change RenderMode According to Current Window Size

The below example demonstrates how to change RadMenu RenderMode, based on the size of current window (view). The change will occur on resize of window, when the given breakpoint is reached. Within the below implementation, for widths below 1000px RenderMode is set to "Mobile". For widths above this value RenderMode is "Lightweight".

<%--The RadAjaxManager initiates AJAX postback each time RenderMode needs to be changed--%>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" ClientIDMode="Predictable">
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <telerik:AjaxUpdatedControl ControlID="RadMenu1" />

<%--Include a RadStyleSheetManager to your page--%>
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />

<%--This Menu switches depending on the breakpoint that is set in the JavaScript code--%>
    <telerik:RadMenu ID="RadMenu1" runat="server" Width="100%">
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem1">
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem2">
            <telerik:RadMenuItem runat="server" Text="Root RadMenuItem3">

// Breakpoint is set to 1000px
var breakPointsWidth = 1000;

var $ = $telerik.$;
var $T = Telerik.Web.UI;

var ajaxManager;
var bigResolution;
var isInLightweight;
var isInMobile;

function pageLoad() {
    var menu = $find('RadMenu1');

    // Identify the current RadMenu RenderMode
    var currentRenderMode = menu.get_renderMode();
    isInLightweight = currentRenderMode === $T.RenderMode.Lite;
    isInMobile = currentRenderMode === $T.RenderMode.Mobile;

    ajaxManager = $find('RadAjaxManager1');


$(window).resize(function () {

function verifyRenderModeAgainsResolution() {
    // Identify current window size
    bigResolution = ($(window).width() > breakPointsWidth);
    if ((bigResolution && !isInLightweight) || (!bigResolution && !isInMobile)) {

function changeRenderMode() {
    // Initiate AJAX request using RadAjaxManager
    isInMobile = !isInMobile;
    isInLightweight = !isInLightweight;

protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    if (Boolean.Parse(e.Argument))
        RadMenu1.RenderMode = RenderMode.Lightweight;
        RadMenu1.RenderMode = RenderMode.Mobile;
Protected Sub RadAjaxManager1_AjaxRequest(sender As Object, e As AjaxRequestEventArgs)
    If [Boolean].Parse(e.Argument) Then
        RadMenu1.RenderMode = RenderMode.Lightweight
        RadMenu1.RenderMode = RenderMode.Mobile
    End If
End Sub

See Also

In this article