asp.net中如何获取textbox.value属性

来源:百度知道 编辑:UC知道 时间:2024/05/22 03:42:38
我想通过打开一个新窗口选择里面的信息到一个文本框里面,然后再将选择的信息加入数据库,这就存在一个问题,对于Textbox控件,在Javascript里面是用 .value属性给它赋值,但是在asp.net里面Textbox并没有.value属性,只有.text属性如何实现.value和.text属性的转变呢?

我的两个文件内容如下:
Index.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="AgeIndex" %>
<html>
<head runat="server">
<title>主页测试</title>
<link href="train/train.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function opendialog()
{
var TheReturnValue=window.showModalDialog("TheDialog.aspx","","dialogWidth=450px;dialogHeight=400px;status=no;help=no;scrollbars=no")
document.form1.txtFrom.value=TheReturnValue;
}
</script>
<body>

<asp:Panel runat="server"

sqlstr = "INSERT INTO AgePerson(Pname,Pbirth,Pfrom)VALUES('" + this.txtName.Text + "','" + this.txtBirth.Text + "','" + this.txtFrom.Text + "')";
把This 去掉
改成 txtName.Text.ToString();其他也一样

document.getElementById("txtFrom").value=TheReturnValue;