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. Moving from one page and back

Moving from one page and back

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestionlearning
5 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.
  • B Offline
    B Offline
    Britnt7
    wrote on last edited by
    #1

    How do you use a button in VB.Net to jump back and forth from page to page? Is it possible to pull a value from the other page? If so how?:sigh: Thanks in advance, Beginner in VB and ASP.NET

    A 1 Reply Last reply
    0
    • B Britnt7

      How do you use a button in VB.Net to jump back and forth from page to page? Is it possible to pull a value from the other page? If so how?:sigh: Thanks in advance, Beginner in VB and ASP.NET

      A Offline
      A Offline
      Andrew Quinn AUS
      wrote on last edited by
      #2

      Hi, You can handle the OnClick event for the button, e.g.

      Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Session("Text1") = TextBox1.Text
          Server.Transfer("WebForm2.aspx")
      End Sub
      

      So when the button is pressed, we've taken the value from a textbox that's in the page also, set it to the session object and then transferred control to the WebForm2.aspx page. Then in WebForm2.aspx you can access the value...

      Private Sub Page\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Label1.Text = Session("Text1")
      End Sub
      
      Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Server.Transfer("WebForm1.aspx")
      End Sub
      

      We also handle an OnClick event for a button in this page that returns back to WebForm1.aspx (or wherever you want it to go). I've put the code in VB this time :) Hope this helps, Andy

      B 1 Reply Last reply
      0
      • A Andrew Quinn AUS

        Hi, You can handle the OnClick event for the button, e.g.

        Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Session("Text1") = TextBox1.Text
            Server.Transfer("WebForm2.aspx")
        End Sub
        

        So when the button is pressed, we've taken the value from a textbox that's in the page also, set it to the session object and then transferred control to the WebForm2.aspx page. Then in WebForm2.aspx you can access the value...

        Private Sub Page\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Label1.Text = Session("Text1")
        End Sub
        
        Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Server.Transfer("WebForm1.aspx")
        End Sub
        

        We also handle an OnClick event for a button in this page that returns back to WebForm1.aspx (or wherever you want it to go). I've put the code in VB this time :) Hope this helps, Andy

        B Offline
        B Offline
        Britnt7
        wrote on last edited by
        #3

        Thank you so very much!:-D You sure do know your coding. This will be my last question for you today: if directory Now.ToString("MMyy") exist in "C:\" then show directory else show the last directory Somehow I have to loop through until I get to an existing directory. For example: The latest directory is 0304. If I would check now.tostring(MMyy") then it would start at 0704 then check 0604 then check 0504... until it got to an existing directory called 0304 then show that directory. Seems complicated to me but I know it will be simple for you.;) Thanks again. Beginner in VB and ASP.NET

        A 1 Reply Last reply
        0
        • B Britnt7

          Thank you so very much!:-D You sure do know your coding. This will be my last question for you today: if directory Now.ToString("MMyy") exist in "C:\" then show directory else show the last directory Somehow I have to loop through until I get to an existing directory. For example: The latest directory is 0304. If I would check now.tostring(MMyy") then it would start at 0704 then check 0604 then check 0504... until it got to an existing directory called 0304 then show that directory. Seems complicated to me but I know it will be simple for you.;) Thanks again. Beginner in VB and ASP.NET

          A Offline
          A Offline
          Andrew Quinn AUS
          wrote on last edited by
          #4

          Something like this should do...

              Dim dirDate As Date
              Dim dirStrDate As String
          
              dirDate = Now()
              dirDate = dirDate.AddMonths(1)
          
              Do
                  dirDate = dirDate.AddMonths(-1)
                  dirStrDate = String.Format("C:\\{0}", dirDate.ToString("MMyy"))
              Loop Until System.IO.Directory.Exists(dirStrDate)
          

          dirStrDate will have the directory path of the first existing directory found. Remember though that if this code DOES NOT find any directory in the format you've mentioned IT WILL LOOP FOREVER - so either a change to the code is needed or make sure that a directory (e.g. C:\0101) exists as a fallback. Hope this helps, Andy

          B 1 Reply Last reply
          0
          • A Andrew Quinn AUS

            Something like this should do...

                Dim dirDate As Date
                Dim dirStrDate As String
            
                dirDate = Now()
                dirDate = dirDate.AddMonths(1)
            
                Do
                    dirDate = dirDate.AddMonths(-1)
                    dirStrDate = String.Format("C:\\{0}", dirDate.ToString("MMyy"))
                Loop Until System.IO.Directory.Exists(dirStrDate)
            

            dirStrDate will have the directory path of the first existing directory found. Remember though that if this code DOES NOT find any directory in the format you've mentioned IT WILL LOOP FOREVER - so either a change to the code is needed or make sure that a directory (e.g. C:\0101) exists as a fallback. Hope this helps, Andy

            B Offline
            B Offline
            Britnt7
            wrote on last edited by
            #5

            Later, I will add a counter to the loop so when the counter reaches 12 then it will exit the loop and display that there isn't anything to display. Everything seems to work on a system directory but what do I need to change to search a network directory?

            Do
            dirDate = dirDate.AddMonths(-1)
            dirStrDate = String.Format("K:\testgtb\ats\billing\{0}", dirDate.ToString("MMyy"))
            If count > 11 Then
            lblWarning.Text = "There is no invoices in the customers directory!"
            Exit Do
            Else
            count += 1
            End If
            Loop Until System.IO.Directory.Exists(dirStrDate)

            There is a directory 0304 in K:\testgtb\ats\billing\ directory but it seems like it doesn't see it and keeps searching. What do I need to change to see the network directory?:doh: Thanks again AndyQ!!;) Beginner in VB and ASP.NET

            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