|
-
Dec 9th, 2004, 11:17 AM
#1
Thread Starter
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|