Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing a field on my web form
Message
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00923442
Message ID:
00924034
Views:
37
I see that at the server end you set txtReminderTime (you must have an ID ie: myID) = Session("AlarmTime"). Once you have set the value of a textbox you can grab it at the browser level as we discussed previously. This a cool way to have the server and browser comunicate through a textbox, which persists through postbacks.
<script language = "javascript">
  function GetSessionTime()
 {
    var testtime = document.getElementById("myID")
    return testtime
 }
</script>

<script language=' javascript'>
  myTestReminderTime=GetSessionTime()
</script>
  
Also.... If you set a public variable to Session("AlarmTime")
you can access the public variable, at the client side, via the
<%=publicVariableName/%>
syntax

Regards,
Neil



>Neil,
>Thank you again for the solution...
>BTW - do you happen to know this one...
>
>I have a session variable created in the Code Behind section
>I'd like to access it in the HTML section.
>
>I have a datagrid with a "Select" link
>In my Code Behind section I have
>
>Private Sub DataGridActivities_SelectedIndexChanged _
>   (ByVal sender As System.Object, ByVal e As System.EventArgs)_
>   Handles DataGridActivities.SelectedIndexChanged
>   Trace.Write("DataGridActivities_SelectedIndexChanged", _
>               "We're in the DataGridActivities_SelectedIndexChanged event")
>
>   'set the session variable
>   Session("AlarmTime") = _
>IIf(IsDBNull(oledbDS.Tables("Activities").Rows(DataGridActivities.SelectedIndex).Item("Alarm_Status")), _
>    "", _
>    oledbDS.Tables("Activities").Rows(DataGridActivities.SelectedIndex).Item("Alarm_Status"))
>
>   'set the field used to set the alarm time
>   txtReminderTime.Text = Session("AlarmTime")
>End Sub
>
>
>And in my HTML section I have
>
><script language="vbscript" id="clientEventHandlersVBS">
><!--
Sub btnSetAlarm_onclick
	DIM TestDate
	TestDate = DateDiff("d",#01/01/1900#,Now)
	
	dim myReminderTime
	dim myHour
	dim myMinute
	dim mySecond
	
	&lt;%
	myTestReminderTime = Session("AlarmTime")
	%
	
	myReminderTime = GetTextBoxValue()
	myHour = hour(myReminderTime)
	myMinute = minute(myReminderTime)
	mySecond = second(myReminderTime)+5
	Call ctAlarm1.SetTimeAlarm(TestDate, myHour, myMinute, mySecond)

	msgbox("Alarm set to fire at=" & TestDate & " - myReminderTime=" & myReminderTime)

	msgbox("myHour=" & myHour & " myMinute=" & myMinute & " mySecond=" & mySecond)

	msgbox("myTestReminderTime=" & myTestReminderTime)
End Sub
-->
></script>
>
>
>
>The problem is
>myTestReminderTime = Session("AlarmTime")
>does not set myTestReminderTime to the alarm time
>
>Do you know what I did wrong?
>
>TIA,
>Rick
>
>>Rick,
>>Try this. Make certain you have the TextBox's ID.
>>
>><script language = 'javascript'>
>>  function GetTextBoxValue{
>>    var oTextBox = document.getElementById('TextBoxID')
>>    return oTextBox.value
>>  }
>></script>
>>
>>Check out: http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.html
>>
>>>It must be one of those days!
>>>I'm completely drawing a blank. I hope someone can remind me...
>>>I have a Web form with a textbox and a HTML button on the page.
>>>When the user clicks the HTML button it calls a VBScript. In the subroutine in the VBScript I want to access the current value of the textbox and pass that value on as a parameter to another function. The other function is a call to an ActiveX component (ctAalarm.OCX)
>>>The value of the textbox is the time I want to send to the ActiveX alarm.
>>>
>>>TIA,
>>>Rick
Previous
Reply
Map
View

Click here to load this message in the networking platform