Telerik Device.Detection sample code

Responsive design isn’t just about CSS breakpoints anymore. When you’re working inside classic ASP.NET WebForms — especially with Telerik controls — you have an extra layer of intelligence available to you: server-side device detection. Instead of waiting for the browser to decide how your layout should behave, Telerik lets you detect the visitor’s device size on the server and adjust your UI before the page even renders.

This is incredibly useful when you’re dealing with controls like RadSiteMap, RadMenu, or RadGrid, where layout decisions often need to be made early in the page lifecycle. The snippet below shows exactly how to detect a small-screen device and automatically switch your site map into a single-column layout for mobile users.

Related Articles

... and you 'll find more on the Telerik ASPNET Menu

Telerik’s Device Detection Framework gives WebForms developers something that modern CSS alone can’t: server-side awareness of the user’s screen size. Instead of relying solely on media queries or JavaScript, Telerik inspects the incoming UserAgent and classifies the device into one of several buckets — Small, Medium, Large, or ExtraLarge.

Once you know the device category, you can tailor your UI before the page renders. This is especially powerful for controls that generate complex HTML structures, such as RadSiteMap. On a desktop, a multi-column site map looks clean and efficient. But on a phone, those same columns become cramped and unreadable. With device detection, you can switch layouts automatically.

In the example above, the code checks whether the visitor is using a small-screen device. If so, it grabs the first SiteMapLevelSetting and forces the site map into a single-column layout. The result is a mobile-friendly navigation experience without needing a separate page, separate CSS file, or client-side script.

For WebForms developers who want responsive behavior without rewriting their entire UI, Telerik’s device detection is a practical, low-friction solution. It lets you keep your existing controls, keep your existing markup, and still deliver a layout that adapts intelligently to the user’s device.

 

 

Dim screenSize As DeviceScreenSize = Detector.GetScreenSize(Request.UserAgent)
If screenSize = DeviceScreenSize.Small Then
    Dim oSiteMapLevelSetting As Telerik.Web.UI.SiteMapLevelSetting = SiteMap1.LevelSettings(0)
    oSiteMapLevelSetting.ListLayout.RepeatColumns = 1
End If

 

 


RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences