改变按钮disabled属性遇到的问题
[code=VB.NET][/code]%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script runat ="server" language ="vbscript">
Sub op_browse(ByVal sender As Object, ByVal e As EventArgs)
Dim i As Integer
For i = 0 To panel.Controls.Count - 1
Dim obj As Object = panel.Controls(i)
If Not obj.ToString() = "System.Web.UI.LiteralControl" Then
obj.disabled = False
End If
Next
Select Case sender.value
Case "浏览"
For i = 0 To panel.Controls.Count - 1
Dim obj As Object = panel.Controls(i)
If Not obj.ToString() = "System.Web.UI.LiteralControl" Then
obj.disabled = True
End If
Next
opmode("browse")
Case "新增"
opmode("edit")
Case "编辑"
opmode("edit")
Case "放弃"
opmode("browse")
Case "保存"
opmode("browse")
End Select
End Sub
Sub opmode(ByVal op As String)
Select Case op
Case "browse"
cmd_bro.Disabled = False
cmd_add.Disabled = False
cmd_save.Disabled = False
cmd_edit.Disabled = False
cmd_cancel.Disabled = True
cmd_save.Disabled = True
Case "edit"
cmd_bro.disabled = True
cmd_add.disabled = True
cmd_save.disabled = True
cmd_edit.disabled = False
cmd_cancel.Disabled = False
cmd_save.disabled = False
End Select
End Sub
</script>
</head>
<body>
<form id="form1" runat="server" method="post">
<div id="panel" runat ="server">
姓名:<input id="Text1" type="text" runat="server" /><br />
<br />
性别:<input id="Radio1" type="radio" name="sex" value ="radio2" runat="server" />男
<input id="Radio2" type="radio" name="sex" value ="radio2" runat="server" />女<br />
<br />
地址:<input id="Text2" type="text" runat="server" /><br />
<br />
电话:<input id="Text3" type="text" runat="server" /><br />
<br />
建议类型:<select style="width: 64px; height: 56px">
<option value ="网站"selected="selected">网站</option>
<option value="服务">服务</option>
<option value="课程">课程</option>
<option value ="其他">其他</option>
</select><br />
<br />
建议内容:<br />
<textarea id="TextArea1" cols="53" rows="6" runat="server"></textarea><br />
<br />
<input id="cmd_bro" type="button" value="浏览" runat="server" onserverclick="op_browse"/>
<input id="cmd_add" type="button" value="新增" runat="server" onserverclick="op_browse"/>
<input id="cmd_edit" type="button" value="编辑" runat="server" onserverclick="op_browse"/>
<input id="cmd_save" type="button" value="保存" runat="server" onserverclick="op_browse"/>
<input id="cmd_cancel" type="button" value="放弃" runat="server" onserverclick="op_browse"/><br />
</div>
</form>
</body>
</html>
它提示:
“/mysite”应用程序中的服务器错误。
--------------------------------------------
未找到类型“ResourceBasedLiteralControl”的公共成员“disabled”。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.MissingMemberException: 未找到类型“ResourceBasedLiteralControl”的公共成员“disabled”。
源错误:
[解决办法]
If Not obj.ToString() = "System.Web.UI.LiteralControl"
控件类写错了!!