在后台我是这样添加控件的
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Write(quyu_shiyonglv());
}
} public string quyu_shiyonglv()
{
string strBody = null;
strBody += "<ul>";
strBody += " <li>";
strBody += " <input type='checkbox' id='1' /><a href='http://baidu.com'>1</a><select id='ass'runat='server'><option value='1'>21a</option>";
strBody += "<option value='1'>22a</option></select>";
strBody += " <ul>";
strBody += " <li>4";
strBody += " <ul>";
strBody += " <li>5 </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += "</ul>";
strBody += " ---------------------------------------------- ";
return strBody;
}
}然后我添加个后台事件
protected void btn_Click(object sender, EventArgs e)
{
这里怎么获取上面控件的值;
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Write(quyu_shiyonglv());
}
} public string quyu_shiyonglv()
{
string strBody = null;
strBody += "<ul>";
strBody += " <li>";
strBody += " <input type='checkbox' id='1' /><a href='http://baidu.com'>1</a><select id='ass'runat='server'><option value='1'>21a</option>";
strBody += "<option value='1'>22a</option></select>";
strBody += " <ul>";
strBody += " <li>4";
strBody += " <ul>";
strBody += " <li>5 </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += "</ul>";
strBody += " ---------------------------------------------- ";
return strBody;
}
}然后我添加个后台事件
protected void btn_Click(object sender, EventArgs e)
{
这里怎么获取上面控件的值;
}
解决方案 »
- column”参数不能为空。
- 请问在ASP.NET如何输出SQL查询语句的值?
- dataset和datareader那个更好?如果只是取一个表的数据?
- ASP.Net运行的问题
- 关于在数据库找不到数据就返回null的程序写法
- 20分求解播放完flash动画,跳转到另一个页面的问题
- 使用asp .net在iis服务器端生成word文档失败,求解!!!
- 在线等,在使用用户控件中的DataGrid时引发了关于CurrentPageIndex错误.
- 怎样同时使用upload上传组件和replace
- asp.net core+ef+mysql 不能使用take?
- 关于area标签的问题
- 谁知道怎么在小说网站上面导入别的网站上的数据进去
<select name='ass'>Request.Params.Get("ass")
获得
也是不行的,这样不能放在form里面了,
你需要放一个Literal控件或者使用<%=%>插入到form内
<%@ Page Language="C#" AutoEventWireup="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server"> protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Literal1.Text = quyu_shiyonglv();
}
} public string quyu_shiyonglv()
{
string strBody = null;
strBody += "<ul>";
strBody += " <li>";
strBody += " <input type='checkbox' id='1' /><a href='http://baidu.com'>1</a><select name='ass'><option value='1'>21a</option>";
strBody += "<option value='2'>22a</option></select>";
strBody += " <ul>";
strBody += " <li>4";
strBody += " <ul>";
strBody += " <li>5 </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += "</ul>";
strBody += " ---------------------------------------------- ";
return strBody;
} protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(Request.Params.Get("ass"));
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form runat="server" id="form1">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</form>
</body>
</html>
{
string strBody = null;
strBody += "<ul>";
strBody += " <li>";
strBody += " <input type='checkbox' id='1' /><a href='http://baidu.com'>1</a><select id='ass'runat='server'><option value='1'>21a</option>";
strBody += "<option value='1'>22a</option></select>";
strBody += " <ul>";
strBody += " <li>4";
strBody += " <ul>";
strBody += " <li>5 </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += " </ul>";
strBody += " </li>";
strBody += "</ul>";
strBody += " ---------------------------------------------- ";
return strBody;
}
}你这段代码不许是在form表单里面还有你每个空间都要加一个name属性
后台你可以通过request.form[name]来得到值。