aspx页面中html控件如何传值到服务器

xixuan_sky 2009-03-12 01:37:37
aspx页面中html控件如何传值到服务器,
比如说是注册的是两个input 如何注册到服务器?这个搞不清楚,请指点详细
...全文
259 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
laoban 2009-03-12
  • 打赏
  • 举报
回复
设置input的runat属性为"server"
  • 打赏
  • 举报
回复
form1 的 method="post" 的话

<form name="form1" method="post" >

这里
string v = Request.QueryString["input1"];

改为
string v = Request.Form["input1"];
  • 打赏
  • 举报
回复
HTML文件内容:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script language="javascript" type="text/javascript">
// <!CDATA[

function Button1_onclick() {
form1.action = "deal.aspx";
form1.submit();
return;
}

// ]]>
</script>
</head>
<body>
<form name="form1">
<p>
 </p>
<p>
<input id="Text1" name="input1" type="text" /><input id="Button1" type="button"
value="button" onclick="return Button1_onclick()" /></p>
</form>
</body>
</html>


在deal.aspx 处理数据。

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string v = Request.QueryString["input1"];
this.Label1.Text = v;
}

}
guichuan 2009-03-12
  • 打赏
  • 举报
回复
Request.Form可以获取Post过去表单的数据

syc958 2009-03-12
  • 打赏
  • 举报
回复
post过去呗..
阿非 2009-03-12
  • 打赏
  • 举报
回复

<input type="text" id="txt1" name="txt2" />
<input type="text" id="txtOne" name="txtOne" />
<asp:Button ID="btn" runat="server" Text="提交" OnClick="btn_Click" />
<asp:TextBox ID="txtServer1" runat="server"></asp:TextBox>
<asp:TextBox ID="txtServerOne" runat="server"></asp:TextBox>



protected void btn_Click(object sender, EventArgs e)
{
txtServer1.Text = string.IsNullOrEmpty(Request.Form["txt1"]) ? "值为空" : Request.Form["txt1"];
txtServerOne.Text = string.IsNullOrEmpty(Request.Form["txtOne"]) ? "值为空" : Request.Form["txtONe"];
}

txtONe 是特意这么写的
黑哥 2009-03-12
  • 打赏
  • 举报
回复
他们确实有点点关系。
arjsyy 2009-03-12
  • 打赏
  • 举报
回复
1.可以给html控件加上runat='server'属性变成服务器控件,
2.Request.form['名称']
3.使用ajax技术
xixuan_sky 2009-03-12
  • 打赏
  • 举报
回复
关键是有些页面不想使用服务器控件,给个实例也行啊
mengfeihui 2009-03-12
  • 打赏
  • 举报
回复
runat = server 声明成服务器控件不就可以了
还可以 加上 return false 防止刷新。。
xixuan_sky 2009-03-12
  • 打赏
  • 举报
回复
还不是很明白,页面上的html控件是如何和asp.cs文件找到关系的
zzxap 2009-03-12
  • 打赏
  • 举报
回复
<inpu type="text" name="aaa">
PostBack后通过Reqeust.Form["aaa"]就可以获得
阿非 2009-03-12
  • 打赏
  • 举报
回复

Request.Form
zzxap 2009-03-12
  • 打赏
  • 举报
回复
提交表单就行了
CutBug 2009-03-12
  • 打赏
  • 举报
回复
aspx页面中html控件如何传值到服务器,
——————————————————————
<inpu type="text" name="aaa">
PostBack后通过Reqeust.Form["aaa"]就可以获得
xixuan_sky 2009-03-12
  • 打赏
  • 举报
回复
楼上的能说的详细点吗?
xixuan_sky 2009-03-12
  • 打赏
  • 举报
回复
自己先顶一下
whoami333 2009-03-12
  • 打赏
  • 举报
回复
用js传给hiddenfield.

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧