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

  • SEARCH
  • Home
  • 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 4575328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:02:52+00:00 2026-05-21T20:02:52+00:00

I have a MainPage.Master and another ContentPage.Master which uses MainPage.master as its masterpage (

  • 0

I have a MainPage.Master and another ContentPage.Master which uses MainPage.master as its masterpage ( i think it ‘inherits’ the main master page? not sure on terminology..)

On MainPage.Master.cs I have code within Page_Load which queries a database and returns an int (which is a count of total number of rows in a DataTable) this on each page load updates an asp:literal with some html which includes the int. This works fine during changing pages but not on postback.

For instance when a user clicks a button that adds to this DataTable it is getting added but the asp:literal doesn’t change untill I click a link which changes the page.

So to recap; it adds to the DataTable but doesn’t update the count in the asp:literal. I think this has something to do with postbacks but not sure what to do..

The code from MasterPage.master.cs:

    protected void Page_Load(object sender, EventArgs e)
{
    if (Session["OrderID"] == null)
    {
        NoItemsInCart.Text = "<span class=\"ajax_cart_no_product\">0 items</span>";
    }
    else
    {
        var itemsincart = Cart.ItemsInCart((int)Session["OrderID"]);
        NoItemsInCart.Text = string.Format("<span class=\"ajax_cart_no_product\">{0} item(s)</span>", itemsincart);
    }
}

So this code does actually work but not initialy when a user clicks the button to add to the DataTable. When I navigate to another page it updates and shows the correct number.

Thanks,

Michael

  • 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-05-21T20:02:53+00:00Added an answer on May 21, 2026 at 8:02 pm

    If you want this to change when the user clicks a button, add it to the event method rather than on the page load. This should then work for you.

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

Sidebar

Related Questions

I have a main page which looks like: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage
I have a Page in Silverlight which is Navigated from the MainPage.xaml, called OpenPage.xaml,
I have an PHP/HTML main page, in which I include different other PHP files
On my main page I have this jquery code which does an ajax call
I have a site which uses Shadowbox-JS to bring up a settings page when
Im in a page mainpage.aspx in which i have this code: <a rel=facebox href=destination.htm?path=blabla>mainpage</a>
I have a like button on my main page (master page in asp.net). I
I have a main page from where I am making a call to load
I am using jQuery for a simple website and have a main page 'index.html'
I have in the main page with two principal parts : in the left

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.