主题:为什么vb可以c#不行
<%@ Page Language="VB" %>
<script runat="server">
dim s1 as string
Sub RadioButton_CheckedChanged(sender As Object, e As EventArgs)
s1=sender.Text
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:RadioButton id="RadioButton1" runat="server" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="True" GroupName="r1" Text="3"></asp:RadioButton>
<br />
<asp:RadioButton id="RadioButton3" runat="server" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="True" GroupName="r1" Text="4"></asp:RadioButton>
<br />
<%= s1%>
</form>
</body>
</html>
vb编译通过,显示也正常
<%@ Page Language="C#" %>
<script runat="server">
// Insert page code here
//
string s1;
void RadioButton_CheckedChanged(Object sender, EventArgs e) {
s1 = sender.Text;
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:RadioButton id="RadioButton1" runat="server" GroupName="r1" AutoPostBack="True" OnCheckedChanged="RadioButton_CheckedChanged" Text="4"></asp:RadioButton>
<br />
<asp:RadioButton id="RadioButton3" runat="server" GroupName="r1" AutoPostBack="True" OnCheckedChanged="RadioButton_CheckedChanged" Text="5"></asp:RadioButton>
<br />
<%= s1%>
</form>
</body>
</html>
c#就不行,提示Object 没有text
是为什么呀?
<script runat="server">
dim s1 as string
Sub RadioButton_CheckedChanged(sender As Object, e As EventArgs)
s1=sender.Text
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:RadioButton id="RadioButton1" runat="server" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="True" GroupName="r1" Text="3"></asp:RadioButton>
<br />
<asp:RadioButton id="RadioButton3" runat="server" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="True" GroupName="r1" Text="4"></asp:RadioButton>
<br />
<%= s1%>
</form>
</body>
</html>
vb编译通过,显示也正常
<%@ Page Language="C#" %>
<script runat="server">
// Insert page code here
//
string s1;
void RadioButton_CheckedChanged(Object sender, EventArgs e) {
s1 = sender.Text;
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:RadioButton id="RadioButton1" runat="server" GroupName="r1" AutoPostBack="True" OnCheckedChanged="RadioButton_CheckedChanged" Text="4"></asp:RadioButton>
<br />
<asp:RadioButton id="RadioButton3" runat="server" GroupName="r1" AutoPostBack="True" OnCheckedChanged="RadioButton_CheckedChanged" Text="5"></asp:RadioButton>
<br />
<%= s1%>
</form>
</body>
</html>
c#就不行,提示Object 没有text
是为什么呀?