Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Again classes

Again classes

Scheduled Pinned Locked Moved ASP.NET
helpdatabasequestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chodici Mrkev
    wrote on last edited by
    #1

    My problem is this: I have a class UseDetails.vb, then in page Register.aspx have declared one instance of this class for the whole page. There are procedures GetUserDetails and UpdateUserDetails, I have there this code in page_load Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Select Case Request.QueryString("action") Case "" lblAction.Text = "Registrace nového uživatele" btnSubmit.Text = "Odeslat" Case "new" lblAction.Text = "Registrace nového uživatele" btnSubmit.Text = "Odeslat" Case "edit" lblAction.Text = "Úprava nastavení uživatele" btnSubmit.Text = "Uložit" **GetUserDetails()** End Select in Case "edit" section I call GetUserDetails sub, which sets the textbox values class (there's a sub which gets data from db). Then there's submitbutton_onclick `Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Select Case Request.QueryString("action") Case "" RegisterUser() Case "new" RegisterUser() Case "edit" **UpdateUserDetails()** End Select End Sub` End Sub I call here UpdateUserDetails - this sub saves the updated data from textboxes to class (and sub in class saves it to db) MY PROBLEM: WHEN I CLICK SUBMIT BUTTON, IT CALLS PAGE_LOAD FIRST = IT SUB GETUSERDETAILS = IT OVERWRITE THE DATA CHANGED BY USER AND AFTER THIS IT CALLS SUB UPDATEUSERDETAILS = IT SAVES THE SAME DATA TO DB AS BEFORE UPDATE. Please help? (Should I use something like a Static i=0, i=i+1 in GetUserInfo and then test if i=0 or 1. Or something else?

    C 1 Reply Last reply
    0
    • C Chodici Mrkev

      My problem is this: I have a class UseDetails.vb, then in page Register.aspx have declared one instance of this class for the whole page. There are procedures GetUserDetails and UpdateUserDetails, I have there this code in page_load Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Select Case Request.QueryString("action") Case "" lblAction.Text = "Registrace nového uživatele" btnSubmit.Text = "Odeslat" Case "new" lblAction.Text = "Registrace nového uživatele" btnSubmit.Text = "Odeslat" Case "edit" lblAction.Text = "Úprava nastavení uživatele" btnSubmit.Text = "Uložit" **GetUserDetails()** End Select in Case "edit" section I call GetUserDetails sub, which sets the textbox values class (there's a sub which gets data from db). Then there's submitbutton_onclick `Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Select Case Request.QueryString("action") Case "" RegisterUser() Case "new" RegisterUser() Case "edit" **UpdateUserDetails()** End Select End Sub` End Sub I call here UpdateUserDetails - this sub saves the updated data from textboxes to class (and sub in class saves it to db) MY PROBLEM: WHEN I CLICK SUBMIT BUTTON, IT CALLS PAGE_LOAD FIRST = IT SUB GETUSERDETAILS = IT OVERWRITE THE DATA CHANGED BY USER AND AFTER THIS IT CALLS SUB UPDATEUSERDETAILS = IT SAVES THE SAME DATA TO DB AS BEFORE UPDATE. Please help? (Should I use something like a Static i=0, i=i+1 in GetUserInfo and then test if i=0 or 1. Or something else?

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Chodici Mrkev wrote: MY PROBLEM: WHEN I CLICK SUBMIT BUTTON, IT CALLS PAGE_LOAD FIRST Yes, that is the correct operation. You can use the IsPostBack[^] property on the Page class (which you are inheriting from) to determine if this is the first time the page is loaded, or it is being loaded because of a postback. If you have not turned the ViewState off, then your buttons and labels will not need to be updated again in the Page_Load method. So, you could possible re-write your page load as:

      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      If Not IsPostBack
      Select Case Request.QueryString("action")
      Case ""
      lblAction.Text = "Registrace nového uživatele"
      btnSubmit.Text = "Odeslat"
      Case "new"
      lblAction.Text = "Registrace nového uživatele"
      btnSubmit.Text = "Odeslat"
      Case "edit"
      lblAction.Text = "Úprava nastavení uživatele"
      btnSubmit.Text = "Uložit"
      GetUserDetails()
      End Select
      End If
      ' Remainer of method omitted from the original post

      DISCLAIMER: I am not a VB.NET developer, there may be syntax errors - but the logic should be apparent.


      "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups