首页 新闻 赞助 找找看

我想往后台.cs程序中传递前台.aspx程序的值 怎么传不了

0
悬赏园豆:5 [待解决问题]

前台.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<input id="Hidden1" type="hidden" runat="server"/>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
<script type="text/javascript">
function get()
{
document.getElementById("Hidden1").value = "aaa";
}
</script>
</form>
</body>
</html>

 

后台.aspx.cs

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s = Hidden1.Value;
TextBox1.Text = s;
Label1.Text = Hidden1.Value;
}
}

纸风车_韦的主页 纸风车_韦 | 初学一级 | 园豆:196
提问于:2015-03-31 20:33
< >
分享
所有回答(7)
0

要post才可以。

519740105 | 园豆:5810 (大侠五级) | 2015-03-31 21:33

什么东西??小白 不懂

支持(0) 反对(0) 纸风车_韦 | 园豆:196 (初学一级) | 2015-04-06 09:42

@纸风车_韦: 表单提交,如果还不懂就没办法了

支持(0) 反对(0) 519740105 | 园豆:5810 (大侠五级) | 2015-04-06 09:53

@519740105: 额  能写段代码看看吗

支持(0) 反对(0) 纸风车_韦 | 园豆:196 (初学一级) | 2015-04-07 19:38
0

同上,post

茂茂 | 园豆:2892 (老鸟四级) | 2015-04-01 11:48
0

你得用服务器端事件啊,没见你页面上有button啊

i迷倪 | 园豆:185 (初学一级) | 2015-04-01 12:59

怎么用啊

支持(0) 反对(0) 纸风车_韦 | 园豆:196 (初学一级) | 2015-04-06 09:43
0

1.你的pageload先于页面脚本的执行,hidden.value的值一开始就为空。

2.你的get脚本没有执行,根本没有赋值啊。

3.如果脚本执行了想在后面取到该值,则需要有事件回传到后端。

bulusli | 园豆:331 (菜鸟二级) | 2015-04-01 16:48

怎么做  能给个例子吗

支持(0) 反对(0) 纸风车_韦 | 园豆:196 (初学一级) | 2015-04-30 21:25
0

__doPostBack

问天何必 | 园豆:3311 (老鸟四级) | 2015-04-01 16:55
0

没有提交事件。

肖春光 | 园豆:204 (菜鸟二级) | 2015-04-07 11:21

那该怎么写  能给个详细代码吗

支持(0) 反对(0) 纸风车_韦 | 园豆:196 (初学一级) | 2015-04-30 21:24
0

<form id="form1" runat="server" method=“post” action=“前台.aspx”>

还需要一个<button type="submit">提交</button>就可以了。

猿哥爱码 | 园豆:258 (菜鸟二级) | 2015-08-27 19:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册