这是前台代码<table width="700" ><tr>
<td style="width:150px;" valign="top">
<span> 宿舍类型: </span>
</td>
<td valign="top">
<asp:RadioButtonList ID="dorm" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>标准四人间</asp:ListItem>
<asp:ListItem>标准六人间</asp:ListItem>
<asp:ListItem>普通六人间</asp:ListItem>
<asp:ListItem>普通八人间</asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left" /><br />
</td>
</tr>
<tr><td style="width:150px;" valign="top"> <span>性别:</span> </td>
<td valign="top">
<asp:RadioButtonList ID="sex" runat="server" RepeatDirection="Horizontal" OnTextChanged="sex_TextChanged" AutoPostBack="True">
<asp:ListItem>男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left"/><br />
</td></tr>
<tr><td style="height: 24px" >
<asp:Label ID="lnum" runat="server" Width="150px"></asp:Label></td>
<td style="height: 24px"><asp:Label ID="lnumtext" runat="server" Width="150px"></asp:Label></td>
</tr>
<tr><td colspan="2" align="center">
<asp:Button ID="Button1" runat="server" Height="26px" OnClick="Button1_Click" Text="确认" /></td></tr>
</table>
下面是后台代码:
protected void sex_TextChanged(object sender, EventArgs e)
{
this.lnum.Text="<span style=\"color:blue; font-siz:20px;\"> 楼号:</span>";
String dorm = this.dorm.Text;
String sex = this.sex.Text;
DataAccess da = new DataAccess();
SqlDataReader rdr = da.get("select lnum from apartmentSource where atype = '" + dorm + "' and asex ='" + sex + "'");
String a = "<font style=\"color:black;\">";
while (rdr.Read())
{
a = a + "<input type=\"radio\" name=\"fno\">"+rdr[0]+" ";
}
this.lnumtext.Text = a;//*/
}
protected void Button1_Click(object sender, EventArgs e)
{
String f = Request.Form[fno];
Response.Redirect("dormsearch.aspx?fno=" + f);
}
运行以后出现的错误:
当前上下文中不存在名称“fno”
<td style="width:150px;" valign="top">
<span> 宿舍类型: </span>
</td>
<td valign="top">
<asp:RadioButtonList ID="dorm" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>标准四人间</asp:ListItem>
<asp:ListItem>标准六人间</asp:ListItem>
<asp:ListItem>普通六人间</asp:ListItem>
<asp:ListItem>普通八人间</asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left" /><br />
</td>
</tr>
<tr><td style="width:150px;" valign="top"> <span>性别:</span> </td>
<td valign="top">
<asp:RadioButtonList ID="sex" runat="server" RepeatDirection="Horizontal" OnTextChanged="sex_TextChanged" AutoPostBack="True">
<asp:ListItem>男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left"/><br />
</td></tr>
<tr><td style="height: 24px" >
<asp:Label ID="lnum" runat="server" Width="150px"></asp:Label></td>
<td style="height: 24px"><asp:Label ID="lnumtext" runat="server" Width="150px"></asp:Label></td>
</tr>
<tr><td colspan="2" align="center">
<asp:Button ID="Button1" runat="server" Height="26px" OnClick="Button1_Click" Text="确认" /></td></tr>
</table>
下面是后台代码:
protected void sex_TextChanged(object sender, EventArgs e)
{
this.lnum.Text="<span style=\"color:blue; font-siz:20px;\"> 楼号:</span>";
String dorm = this.dorm.Text;
String sex = this.sex.Text;
DataAccess da = new DataAccess();
SqlDataReader rdr = da.get("select lnum from apartmentSource where atype = '" + dorm + "' and asex ='" + sex + "'");
String a = "<font style=\"color:black;\">";
while (rdr.Read())
{
a = a + "<input type=\"radio\" name=\"fno\">"+rdr[0]+" ";
}
this.lnumtext.Text = a;//*/
}
protected void Button1_Click(object sender, EventArgs e)
{
String f = Request.Form[fno];
Response.Redirect("dormsearch.aspx?fno=" + f);
}
运行以后出现的错误:
当前上下文中不存在名称“fno”
解决方案 »
- 社区论坛框架设计,大家帮忙看一下
- asp.net实现页面自动播放后台读出的音乐文件(如:MP3)
- 对文件的事务处理
- 上传gif木马,我该怎么解决
- 为什么我的加密解不了?(还有分)
- 第二次提问相同的问题: 100分求!
- vs中,工具箱选项html的input(text)等控件runat属性为什么是灰色?
- 200分求助(急!~~):关于Asp.net水晶报表控件(CrystalReportViewer)把报表汇出Excel,报表排版格式的问题,解决问题马上给分!
- 数据类型转换的问题
- 十万火急!!!100分送出!
- 谁用过powertalkbox即时聊天asp.net控件
- 批量插入数据Ado.net事务的问题
<td style="width:150px;" valign="top">
<span> 宿舍类型: </span>
</td>
<td valign="top">
<asp:RadioButtonList ID="dorm" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>标准四人间 </asp:ListItem>
<asp:ListItem>标准六人间 </asp:ListItem>
<asp:ListItem>普通六人间 </asp:ListItem>
<asp:ListItem>普通八人间 </asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left" /> <br />
</td>
</tr>
<tr> <td style="width:150px;" valign="top"> <span>性别: </span> </td>
<td valign="top">
<asp:RadioButtonList ID="sex" runat="server" RepeatDirection="Horizontal" OnTextChanged="sex_TextChanged" AutoPostBack="True">
<asp:ListItem>男 </asp:ListItem>
<asp:ListItem>女 </asp:ListItem>
</asp:RadioButtonList>
<hr style="color:#dce9ef;border-width:thin;" width="450" align="left"/> <br />
</td> </tr>
<tr> <td style="height: 24px" >
<asp:Label ID="lnum" runat="server" Width="150px"> </asp:Label> </td>
<td style="height: 24px"> <asp:Label ID="lnumtext" runat="server" Width="150px"> </asp:Label> </td>
</tr>
<tr> <td colspan="2" align="center">
<asp:Button ID="Button1" runat="server" Height="26px" OnClick="Button1_Click" Text="确认" /> </td> </tr>
</table>
下面是后台代码:
protected void sex_TextChanged(object sender, EventArgs e)
{
this.lnum.Text=" <span style=\"color:blue; font-siz:20px;\"> 楼号: </span>";
String dorm = this.dorm.Text;
String sex = this.sex.Text;
DataAccess da = new DataAccess();
SqlDataReader rdr = da.get("select lnum from apartmentSource where atype = '" + dorm + "' and asex ='" + sex + "'");
String a = " <font style=\"color:black;\">";
while (rdr.Read())
{
a = a + " <input type=\"radio\" name=\"fno\">"+rdr[0]+" ";
}
this.lnumtext.Text = a;//*/
}
protected void Button1_Click(object sender, EventArgs e)
{
String f = Request.Form[fno];
Response.Redirect("dormsearch.aspx?fno=" + f);
}
运行以后出现的错误:
当前上下文中不存在名称“fno”
问题2: 你首先在这边调试看下String f = Request.Form[fno];
Response.Redirect("dormsearch.aspx?fno=" + f); 中f为空不?
不为空 然后在 dormsearch.aspx页 Request.QueryString["fno"].Tostring();
蒽 只能是表单中的元素 根据它的name值来获取