Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8442679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:54:26+00:00 2026-06-10T08:54:26+00:00

My website is a shopping site and by detecting browser headers, it automatically re-sizes/styles

  • 0

My website is a shopping site and by detecting browser headers, it automatically re-sizes/styles and arranges a few bits and pieces for mobile/desktop browsers.

One example of rearranging a few things is the location of a shopping cart.

On a desktop browser view, the shopping cart appears in the right hand margin. The site is designed to be narrower in a mobile browser (ie iPhone) so the right hand margin does not exist when displaying in a mobile browser. In this case, the shopping cart is loaded into the header instead.

Both the head and shopping cart are user controls, whereas the right hand margin is built in the Master Page, thus, the declaration of the shopping cart user control is present in both Master Page and the Header control.

The relevant markup of my MasterPage looks like this

<div class="content">
    <div id="leftMargin" runat="server"></div>
    <div id="centre">
       <asp:ContentPlaceHolder id="centreContent" runat="server">/asp:ContentPlaceHolder>
    </div>
    <div id="rightMargin" runat="server">

        <controls:shopping ID="shoppingBasket" runat="server" />

    </div>
</div>

I then have codebehind, like this:

If Common.isMobile() Then
    leftMargin.Visible = False
    rightMargin.Visible = False
End If

The Header control is similar, except rather the hiding a complete div, it hides a User Control, ie:

Markup:

<div id="miniNav">
    <div id="mobileCart" class="mobileCart insertCart">                    
        <controls:shopping ID="shoppingBasket" runat="server" />
     </div>
     <!--- more buttons --->
</div>

Code:

If Common.isMobile Then
    shoppingBasket.Visible = True
Else
    shoppingBasket.Visible = False
End If

Obviously, but Common.isMobile function is determining whether we’re displaying a mobile-arranged version or not.

So, after a long winded explanation, my actual question is quite simple.

Given the examples above, when the page is rendered in either case, does the server completely ignore the coding/markup/database interaction etc for all hidden elements hidden by using htmlControl.display=false or am I causing the server to have to actually run all these scripts twice, once being wasted as it’s not actually doing anything?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:54:27+00:00Added an answer on June 10, 2026 at 8:54 am

    Your code will always run, it will simply not be rendered the client.

    If you’re concerned about performance, you should either simply not add the user controls to the page. If that is not an option, you could always add additional logic to ignore expensive operations if you are mobile.

    One “cute” way around this is to use a paradigm similar to Visual WebParts, and use a server control to wrap your user controls. Then your control wrappers would like like:

    public class MyServerControl : WebControl
    {
        #region Private Fields
        private const string _ascxPath = @"~/VisualControls/MyUserControl.ascx";
        #endregion
    
        #region Control Events
        protected override void CreateChildControls()
        {
            if (!Common.IsMobile)
            {
                var control = Page.LoadControl(_ascxPath);
                Controls.Add(this.control);
            }   
        }
        #endregion
    }
    

    And just include the MyServerControl instead of the MyUserControl.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm creating a shopping website that will sell computer parts using MVP and asp.net.
I am working on a online shopping website, it will have product images also.
I am trying to build a shopping website with ajax. When a user clicks
I'm working on a shopping cart in a website and I have my items(which
i am currently building a custom shopping cart to my website, it has all
I am in the process of making a website that involves a shopping cart.
I am planning to integrate some opensource shopping cart with my site and I
I'm thinking of building a complete website on top of wordpress. The site will
i'm creating a shopping website. i have a gridview that is bound to an
I have a shopping cart website running classic ASP that needs help during the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.