C#取页面INPUT值 怎么取啊?

来源:百度知道 编辑:UC知道 时间:2024/07/06 16:00:24
<body>
<form id="demoform" runat="server">
 Date Field:
<input class="plain" type="text" id="TextBox1" name="dc" value="" size="19"><a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(document.demoform.dc);return false;"><img
name="popcal" align="middle"src="js/calbtn.gif" width="34" height="22" border="0"
alt=""></a></input>

<iframe width="188" height="166" name ="gToday:datetime:agenda.js:gfPop:plugins_time.js"
id="gToday:datetime:agenda.js:gfPop:plugins_time.js" src="js/ipopeng.htm" scrolling="no"
frameborder="0" style="visibility: visible; z-index: 999; position: absolute;

分太少了

1. 在你的页面上放个asp.net控件命名为txtGetJSValue
2. 放个asp.net按钮Button1

Button1.OnClientClick设为 GetJSValue();

<script>
function GetJSValue()
{
var txt = document.window.getElementById("TextBox1").value;
document.window.getElementById("txtGetJSValue").value=txt;
}
</script>

运行程序试试?

接下来你在CS页面内可以取txtGetJSValue的值了

前台用JS取值的方法是document.getgetElementById(id).value

后台取值的方法是控件先添加runat="Sverver"属性,然后后台直接id.value

楼主,正确答案在这。

如果前台的控件要在后台访问,只需要像这样
<input runt="server" id="TextBox1" />
那么就能在后台访问TextBox1了,就像访问后台控件一样!

你放过我隐藏空控件 选择的时候 直接给赋值 在C# 中就能娶到了

<asp:hiden id="hid1" runat="server">
<script>
function getValue()
{
getElementById(hid1).value=时间的值;
}
</script>

C#里
string strTime=hid1.Value

public par