Results 1 to 2 of 2

Thread: Newb Question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618

    Newb Question

    Ok, long time programmer, new to web development....

    Trying to figure out why my class level variables get reset....here is the code. In my Page_Load, I am setting a TaskID and a UserID. But when I go to Submit, the values have been reset to zero...

    Public Class Task
    Inherits System.Web.UI.Page

    Private intTaskID As System.Int32
    Private intUserID As System.Int32

    ...

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    If Not IsPostBack Then

    intTaskID = CInt(Request.QueryString("TaskID"))

    LoadUsernameList()

    If intTaskID <> -1 Then
    LoadTask()
    Else
    LoadUserID()
    End If

    ...

    End If

    At the end of the Page_Load, intTaskID = 3 and intUserID = 1. But when I click the Submit button (no other actions taken), they are both set to 0 again. Why are they getting reset? Thanks for any help....

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    Dim strSQL As String
    Dim cmd As New SqlClient.SqlCommand
    cmd.Connection = SqlConn

    cmd.Parameters.Add("@UserID", m_intUserID)
    cmd.Parameters.Add("@AssignDate", txtDateAssigned.Text)
    cmd.Parameters.Add("@DueDate", txtDateDue.Text)
    cmd.Parameters.Add("@CompleteDate", txtDateCompleted.Text)
    cmd.Parameters.Add("@Title", txtTitle.Text)
    cmd.Parameters.Add("@Description", txtDescription.Text)
    cmd.Parameters.Add("@Priority", ddlPriority.SelectedIndex)
    cmd.Parameters.Add("@Accepted", ddlAccepted.SelectedIndex)
    cmd.Parameters.Add("@Closed", ddlClosed.SelectedIndex)
    cmd.Parameters.Add("@ManagerNotes", txtManagerNotes.Text)

    If intTaskID > -1 Then

    ...
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Newb Question

    I've only glanced quickly, but can you step through it and follow the value? What are you getting?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width