<label id="ButtonTestResultLabel" style="color:Black; font-size:large" title="Success" visible=true>Please Press Left Button</label>
<% if scanner.ExecuteButtonTest(sessionid, CInt(1)) then
upbuttonresult = true
end if %>
<% ButtonTestResultLabel.Text = "Please Press Down Button"
if scanner.ExecuteButtonTest(sessionid, CInt(2)) then
downbuttonresult = true
end if %>
我想更改标签文本,但是我得到了错误:
脚本中的
分析错误
Microsoft VBScript运行时错误:“800a01a8”
描述:所需对象:“ButtonTestResultLabel”
文件:/prod/keyonstest.asp
在线: 57
如何更改标签文本?
发布于 2012-06-20 03:36:14
我认为您将ASP静态内容与ASP.NET runat="Server“控件混淆。在ASP脚本中没有ID为ButtonTestResultLabel
的对象。您的目标已经实现了,如下所示,但是请注意,您的代码片段没有什么意义,所以我已经编了一些逻辑来演示。
<%
Function ButtonState()
For i = 1 to 4
If scanner.ExecuteButtonTest(sessionid, CInt(i)) then
ButtonState = i
Exit For
End If
Next
End Function
Function ButtonTestResultLabelText()
Select Case ButtonState
Case 1
ButtonTestResultLabelText = "Please Press Down Button"
Case 2
ButtonTestResultLabelText = "Please Press Up Button"
Case 3
ButtonTestResultLabelText = "Please Press Right Button"
Case Else
ButtonTestResultLabelText = "Please Press Left Button"
End Select
End Function
%>
<label id="ButtonTestResultLabel" style="color:Black; font-size:large" title="Success" visible=true><%=ButtonTestResultLabelText%></label>
这里的关键是将<%=...%>
语法嵌入到您希望动态内容出现的html中。
https://stackoverflow.com/questions/11115064
复制