<%@ Page language="c#" Codebehind="WebForm8.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm8" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm8</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function fun1()
{
!不知如何写
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<input type="text" id="txt1" value="client">
<asp:TextBox id="TextBox1" runat="server" Text="server"></asp:TextBox>
</form>
</body>
</HTML>.cs文件中就只有一句
private void Page_Load(object sender, System.EventArgs e)
{
this.TextBox1.Attributes.Add("onclick","fun()");
}我要在fun1()写一段代码让txt1的值等于TextBox1的值,
反正我的意思就是要在fun1()中对TextBox1进行操作(取值和赋值)?????>>>>我要怎么在fun1中写代码??????
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm8</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function fun1()
{
!不知如何写
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<input type="text" id="txt1" value="client">
<asp:TextBox id="TextBox1" runat="server" Text="server"></asp:TextBox>
</form>
</body>
</HTML>.cs文件中就只有一句
private void Page_Load(object sender, System.EventArgs e)
{
this.TextBox1.Attributes.Add("onclick","fun()");
}我要在fun1()写一段代码让txt1的值等于TextBox1的值,
反正我的意思就是要在fun1()中对TextBox1进行操作(取值和赋值)?????>>>>我要怎么在fun1中写代码??????
alert(aa);
{
var textbox1 = Element.FindElementById( "TextBox1" );
if ( textbox1 != null ) {
textbox1.text = "hahahaha";
}
}//大概是这样,不知道函数名记错了没
你那样我试了不行.
{
var textbox1 = Element.FindElementById( "TextBox1" );
if ( textbox1 != null ) {
textbox1.value = "hahahaha";
}
}
this.TextBox1.Attributes.Add("onclick","fun()");那么你在页面上的JAVASCRIPT里面的函数名就是:fun(),而不是你现在代码你面的fun1().这里需要检查一下。<script language=’javascript’>
function fun()
{
document.all. TextBox1.value=document.Form1. txt1.value
}
</script>
{
var textbox1 = document.getElementById( "TextBox1" );
var txt1= document.getElementById("txt1");
if ( textbox1 != null ) {
txt1.value = textbox1.value;
}
}