|
-
Feb 21st, 2002, 04:51 AM
#1
Thread Starter
Hyperactive Member
(RESOLVED) Remembering variables
I've for a form with two text boxes and two buttons. When I click either button a calendar appears so a user can select a date.
The first sub routine is meant to store which button opened the calendar so that the second routine can populate the correct text box, it doesn't
I've declared the variable outside of any sub, but this doesn't seem to work, what am I doing wrong?
Last edited by parkes; Feb 21st, 2002 at 10:17 AM.
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Feb 21st, 2002, 08:59 AM
#2
Hyperactive Member
is the calander a control on the same form as the buttons? (ie, it is just made visible when either button is pressed?)
what causes the first sub routine to execute?
what causes the second subroutine to execute?
what causes the calender to disappear?
-
Feb 21st, 2002, 09:02 AM
#3
Thread Starter
Hyperactive Member
I've just posted the code, nothing complicated about it.
<%@ Import Namespace="System"%>
<%@ Import Namespace="System.Web.UI.WebControls.BaseValidator" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.TableItemStyle" %>
<script language="VB" runat="server">
Dim iOption As Integer
Sub DateChange(objSender As Object, objArgs As EventArgs)
divResult.InnerHtml="--" & iOption
Select Case iOption
Case "0"
txtStartDate.Text=objSender.SelectedDate
Case "1"
txtEndDate.Text=objSender.SelectedDate
End Select
'divResult.InnerHtml ="<b>Change event for control '" & objSender.SelectedDate & "'</b>"
CalLay.visible=False
End Sub
Sub ShowCal(objSender As Object, E as EventArgs)
Select Case objSender.ID
Case "bcal"
iOption=0
Case "bcal1"
iOption=1
End Select
If cal.Visible=False then
CalLay.Visible=True
Else
CalLay.Visible=False
End if
End Sub
</script>
<html>
<head>
<title>ASP.NET</title>
</head>
<body>
<form runat="server">
<table summary="data" border=1>
<tr>
<td><h3>Welcome</h3></td>
</tr>
<tr><td><asp:TextBox id="txtStartDate" Text="" Tooltip="Date" Columns="11" MaxLength="11" ReadOnly="False" AutoPostBack="True" runat="server" /><asp:Button id="bcal" Text="?" tooltip="Show Calendar" runat="server" onClick="ShowCal" /></td></tr>
<tr><td><asp:TextBox id="txtEndDate" Text="" Tooltip="Date" Columns="11" MaxLength="11" ReadOnly="False" AutoPostBack="True" runat="server" /><asp:Button id="bcal1" Text="?" tooltip="Show Calendar" runat="server" onClick="ShowCal" /></td></tr>
<tr>
<td><asp:Label id="myLabel" Text="" runat="server" /></td>
</tr>
<tr><td><p><asp:ValidationSummary id="valSummary" runat="server"
HeaderText="<b>The following errors were found:</b>"
ShowSummary="True"
DisplayMode="List" /> <!--Or BulletList. SingleParagraph --></p></tr>
<!-- Div results -->
<tr>
<td><div id="divResult" EnableViewStatus="False" runat="server" /></td>
</tr>
</table>
<div id="CalLay" runat="server" visible="false"><asp:Calendar id="cal" ShowGridLines="True" ShowTitle="True" FirstDayOfWeek="Default" ShowDayHeader="True" ShowNextPrevMonth="True" SelectedDate="00:00:00" VisibleDate="00:00:00" Tooltip="" AutoPostBack="True" OnSelectionChanged="DateChange" Border="1" BorderColor="DarkBlue" runat="server" Visible="True">
<DayHeaderStyle BackColor="#336699" forecolor="#ffffcc"/>
<SelectedDayStyle BackColor="#990000" forecolor="#ffffcc"/>
</asp:Calendar></div>
</form>
</body>
</html>
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Feb 21st, 2002, 10:14 AM
#4
Both of those subs get called in seperate requests so you have nothing available to pesist that data from one request to another. I know of 2 options. Either use a Session variable or Data cahcing
Cache("myData") = whateverValue
You can then retrieve that value later
Dim myValue As blah
myValue = Cache("myData")
There are probably some other options but these are the only ones I can think of at the moment.
-
Feb 21st, 2002, 10:17 AM
#5
Thread Starter
Hyperactive Member
Great thanks, Cache method worked.
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
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
|