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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:44:16+00:00 2026-05-10T17:44:16+00:00

I created a single page (with code behind .vb) and created Public intFileID As

  • 0

I created a single page (with code behind .vb) and created Public intFileID As Integer

in the Page load I check for the querystring and assign it if available or set intFileID = 0.

Public intFileID As Integer = 0  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load     If Not Page.IsPostBack Then         If Not Request.QueryString('fileid') Is Nothing Then             intFileID = CInt(Request.QueryString('fileid'))         End If          If intFileID > 0 Then             GetFile(intFileID)         End If     End If End Sub  Private Sub GetFile()     'uses intFileID to retrieve the specific record from database and set's the various textbox.text End Sub 

There is a click event for the Submit button that inserts or updates a record based on the value of the intFileID variable. I need to be able to persist that value on postback for it all to work.

The page simply inserts or updates a record in a SQL database. I’m not using a gridview,formview,detailsview, or any other rad type object which persists the key value by itself and I don’t want to use any of them.

How can I persist the value set in intFileID without creating something in the HTML which could possibly be changed.

[EDIT] Changed Page_Load to use ViewState to persist the intFileID value

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load     If Not Page.IsPostBack Then         If Not Request.QueryString('fileid') Is Nothing Then             intFileID = CInt(Request.QueryString('fileid'))         End If          If intFileID > 0 Then             GetFile(intFileID)         End If          ViewState('intFileID') = intFileID     Else         intFileID = ViewState('intFileID')     End If End Sub 
  • 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. 2026-05-10T17:44:16+00:00Added an answer on May 10, 2026 at 5:44 pm

    As others have pointed out, you can store it in the Session or the ViewState. If it’s page specific, I like to store it in the ViewState as opposed to the Session, but I don’t know if one method is generally preferred over the other.

    In VB, you would store an item in the ViewState like:

    ViewState(key) = value 

    And retrieve it like:

    value = ViewState(key) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single spool mbox file that was created with evolution, containing a
I am using a server control on a single web.forms page. I have to
I've got, what I would consider, a simple test web site. A single page
Is it possible to create a single .svc file (WCF Service) that I can
I am using Xerces-c in my project, and would like to create a single
A single Biztalk Server can have multiple Host processes. Is it possible to create
I managed to create a class using CodeDom and add a single method to
How do I create a ListBox in ASP.NET MVC with single selection mode?
I'm trying to create a use-once HTTP server to handle a single callback and
How can I use Doxygen to create the HTML documentation as a single, very

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.