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