〓〓〓 如何在客户端操作WebUserControl?
自己写了一个WebUserControl, 想在客户端操作
(VB.NET语法 跟C#差不多)
服务端代码:
Protected WithEvents test1 As WebUserControl1
Public webClientID1 As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
test1 = New WebUserControl1
webClientID1 = Me.test1.ClientID
End Sub
客户端代码:
function btn_onclick()
{
alert(document.getElementById(<%=webClientID1%>).style.backgroundColor);
}
<head><body>
<uc1:webusercontrol1 id="WebUserControl11" style="LEFT: 0px; POSITION: absolute; TOP: 0px" runat="server"></uc1:webusercontrol1>
</head></body>
如果服务端不写test1 = New WebUserControl1 就报 “test1 未定义”;
如果写了上面这句 就报
document.getElementById(<%=webClientID1%>).style.backgroundColor) 缺少对象
应该怎么正确使用?