新手咨询一个代码问题
运行出错,提示hairclor=tbhair.Text eyeclor=tbeye.Text 出错,对非共享成员的引用要求对象引用;为什么我不能引用textbox的text属性,我记得看过一个程序可以直接访问阿,真郁闷,那个帮我解惑,谢谢!
<HTML>
<HEAD>
<script language="VB" runat="server">
CLASS cx
public hairclor as string
public eyeclor as string
public birthday as date
sub setmyself(Sender As Object, E As EventArgs)
hairclor=tbhair.Text
eyeclor=tbeye.Text
birthday=date(tbbir.Text)
end sub
end class
sub btSubmit_click(Sender As Object, E As EventArgs)
dim week as integer
week=birthday.dayofweek
response.write(hairclor&eyeclor)
end sub
</script>
</HEAD>
<BODY bgcolor="#cccccc">
<font size="5">Sam's Teach Yourself in 21 Days: Day 2, Exercise 1</font><hr>
<p>
<form runat="server" ID="Form1">
hair:
<asp:textbox id="tbhair" runat="server" />
eye:
<asp:textbox id="tbeye" runat="server" />
<asp:button id="btSubmit" Text="Submit" OnClick="btSubmit_Click" runat="server" />
<P>
birthday:
<asp:TextBox id="tbbir" runat="server"></asp:TextBox>
</P>
<P> </P>
<P> </P>
</form>
</BODY>
</HTML>