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

Ask A Question

Stats

  • Questions 205k
  • Answers 205k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Flesler's scrollTo plugin should do what you want. $().scrollTo( $('div… May 12, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer waitpid was specified in POSIX.1 I believe, so you'll have… May 12, 2026 at 9:02 pm
  • Editorial Team
    Editorial Team added an answer The problem is that .NET will always round a double… May 12, 2026 at 9:02 pm

Related Questions

Well this question relates to MVVM pattern and i could good and fast answers
I'm having a right barney getting my head around how everything fits together using
I am passing a string into a hidden field on the page and then
I'm trying to single source a form page which can be in edit mode

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.