我的程序是用databind控件实现的,就是通过文本框输入名字得到年龄,但是这个程序得不到年龄,错在哪里,怎么修改,一定要使用databind控件,代码如下;
script language="c#" runat="server">
public string user;
public void Page_load(Object src,EventArgs e)
{
Page.DataBind();
user=lblshow.Text;
}
public void bn_click(Object sender,EventArgs e)
{
user=lblshow.Text;
getage(user);
}
public int getage(string uid)
{
int age=0;
switch(uid)
{
case"飞刀":age=21;break;
case"布丁":age=25;break;
case"大风":age=23;break;
case"Zsir":age=26;break;
}
return age;
}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server">
<asp:TextBox ID="lblshow" runat="server"/>
<asp:Button ID="bn" Text="提交" runat="server" OnClick="bn_click"/><br>
</form>
<%=user%>年龄是:<%# getage(user)%>
</body>
</html>