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 6857095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:58:18+00:00 2026-05-27T01:58:18+00:00

I am writing my very first asp.net application and am trying to use the

  • 0

I am writing my very first asp.net application and am trying to use the PreviousPage property to access data between pages. Visual 2010 is giving me an error which I don’t understand, so I need some help to understand what I am doing wrong.

I have an application where I will bounce between all the pages using Transfer. That way, from a user perspective there is only ever one url that he sees. This url will be the one that makes him log in to the application (a application controlled function for now) and connect to the database. I therefore have an sqlclient.sqlconnection object that I wish to hand off to the next page called _dbConnection this is a private variable in my page class declared …

   Partial Class Protocol
        Inherits System.Web.UI.Page
        Private _dbconnection As SqlClient.SqlConnection
        Public ReadOnly Property dbConnection As SqlClient.SqlConnection
            Get
                Return _dbConnection
            End Get
        End Property
        ...

Later down the code, in reponse to a click event on a button

Server.Transfer("PSetup.aspx")

In PSetup.aspx I have the following

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="True" CodeFile="PSetup.aspx.vb" Inherits="PSetup" %>
<%@ PreviousPageType VirtualPath="~/Protocol.aspx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

Which should declare the Protocol class as the previous page

However in PSetup’s Page_Load Sub I attempt this

_dbConnection = PreviousPage.dbConnection

where in this use _dbConnection is a private variable in the new page class.

Visual Studio is giving me an error ‘dbConnection’ is not a member of ‘System.Web.UI.Page’

I have read through the documentation about this several times and I just don’t understand what I am doing wrong. Could someone help me please.

  • 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-27T01:58:19+00:00Added an answer on May 27, 2026 at 1:58 am

    I guess the first thing you need to understand is that ASP.NET is stateless. That means that no data is “saved” between pages. What the PreviousPage property does is it allows the request information persist through the use of a Transfer method, and the request information will be the GET or POST variables.

    IMHO, the best way to do what you desire, is to have a shared public class that is not related to either page, and have a public function for getting the SqlConnection. Remember though, it is stateless, so you will have to create the connection each time.

    Another alternative would be to save the dbConnection in the session (which I don’t recommend, since it is possible to view the session information).

    Otherwise, you can’t have a variable persist with information between pages. Thats what is means to be stateless.

    ALSO, for PreviousPage, keep in mind that it is creating an instance of System.Web.UI.Page, not an instance of Protocol. That means public properties won’t exist from Protocol, only native features of Page will be there.

    edit

    From msdn

    Note

    Properties on the source page that are created primarily to expose values for cross-page posting are usually read-only properties. Although the source page can contain public read/write properties, setting a source page property from the target page property generally has no purpose, because the value will not be persisted.

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

Sidebar

Related Questions

My issue is I am trying my first attempt at writing a very basic
I recently played around with the ASP.NET WebAPI, including some Html-Pages displaying results, trying
I have just started writing a multilingual application for the very first time. I
The context I have an Asp .Net web application with some pages that inherit
Writing my first, very simple Rails application, a simple admin app to track work
First off, I'm very new to Azure. I've successfully deployed an ASP.NET MVC 3
Since the very begining of writing ASP.NET applications when I wanted to add a
I am writing a very simple application, for the iPhone. Unfortunately I am really
I'm writing a very Simple Chat Application and would like to know how to
I'm writing a very simple and small wrapper around sqlite3, and use sqlite3_get_table() to

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.