What / where is page scope on code behind page?

Discussion in 'Site Programming, Development and Design' started by Charlie, Apr 9, 2010.

  1. I have searched google. I think the question may be too basic or the question does not make sense.

    The instructions for what I am trying to achieve refere to a code behind page and say this:

    "Now we will work little bit on the code-behind of the Default.aspx. Declare a PagedDataSource object at page scope."

    I assumed that page scope would be at the top of the code after the imports and page reference and just inside the first bracket. ie. here ( the red writing in the following ) :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;


    public partial class default : System.Web.UI.Page

    {

    PagedDataSource pds = new PagedDataSource();

    various other events
    }


    My page is almost doing what it should be but not quite so I need to try and fathom my mistake. Can anyone tell me - is my understanding re the position of the PagedDataSource correct.

    Advice is greatly appreciated:)
     
  2. Ray

    Ray

  3. Thanks for that Ray. It very interesting. My truth is that I am more at this stage http://www.informit.com/articles/article.aspx?p=25467&seqNum=5 (The Structure of an ASP.NET Page ). However I have very nearly achieved all the web work needed to get my business back on its feet which is a serious priority for my present time. I do have a pager and it is very close to working - see here: http://shifting.w02.Winhost.com/WholesaleCSHARP_2.aspx.

    The user interface of the pager is doing all that I expect it to apart from changing the page size which is a source of frustration but I will sort it out. I have had to use loads of trial and error and upload to Winhost re every little change to debug to get this far because the pager article expects people to have more experience than me and my Vista Home Basic will not debug the code behind page. I am sure the solution to get pager working is simple because it is from a very good article with a working example ( http://www.aspdotnetcodes.com/Dynamic_Paging_DataList_Sample.aspx ) and the response comments are generally excellent re its simplicity and functionality. - I will get there with this pager.

    I have three small things to do before I can upload my site ready for business:

    1) Work out why my page display size ( datatable ie. this post ) is not being influenced by my paging technique - and fix it.

    2) Suss out how to declare a scaler variable in the code behind of the datalist so that users can filter my products with a dropdownlist and textbox like my other page does (but without a pager) - shown here - http://shifting.w02.Winhost.com/Wholesale.aspx

    3) Work out how to pull the text out of a template label to join other text in a textbox on a separate part of the page (using VB), which I know how to do on a normal web page ( something like EventOnClick / Textbox1= Label1.Text & Textbox1.Text - but I have not worked out how to do it from within a datalist ItemTemplate yet. That's so my customers can simply put a number in a box and click a picture to create a written order.

    Three small steps and then I have time to hobby and enjoy learning the general possibilities that all of the ASP.NET lessons out there offer - which I am really grateful for and looking forward to but at this time it is busine$$ which is the most important step to be taken in my world.

    Thanks for the link - its in my favourites - but I have spent 4 days solid getting to where I am with the existing paging control - if you visit the link above, I am sure you will see the logic in me sticking with it considering how close I am to getting it working.

    To round off this post, I should say that if it wasn't for support at Winhost and its excellent product package I would be in a very much more difficult position in my work life than I am :):):) One way or another my professional looking and functional website will be up and running within approx 14 days if not before - something that I could never have achieved without Winhost.
     
    Last edited by a moderator: Oct 14, 2015
  4. Your link actually did answer my question re where page scope is on a page. Although it did not use the phrase page scope it does say.

    "make the PagedDataSource object available tall the code in the page. To accomplish this, we simply remove this line from inside doPaging() and place it just above all the sub-routines"

    I can rule that out as a possible cause of my pager not working now which is very helpful. Thanks:)
     
  5. I decided it was probably worth looking more closely the tutorial link you provided - http://articles.sitepoint.com/articl...ageddatasource from a getting experience perspective.

    I did find it of significant interest but I could not complete it for the following reasons.

    Firstly it is a 2002 article so confidence in its accuracy for current day use is limited and errors cannot be taken for granted as a user error.

    The HTML for the datalist is not followed by datasource code and the only info given in the script is "mockdata" leaving datasource and connection a bit of a taboo to a newbie using software from 5 years into the tutorials future.

    Although it was interesting, for anyone who has arrived at this thread hoping to use a PageDataSource to implement a datalist - http://www.aspdotnetcodes.com/Dynami...st_Sample.aspx - is much more up to date and seriously highly commended by its users. If anyone has any suggestions as to which type of basic error mine is suffering from ( se here http://shifting.w02.Winhost.com/WholesaleCSHARP_2.aspx ) I would be very grateful.
     
    Last edited by a moderator: Oct 14, 2015

Share This Page