javascript改变asp:textbox的值,如何触发OnTextChanged 事件

转(From web):

<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="MyWap.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</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>
function xx()
{
var txt = '<%=TextBox1.ClientID%>';
document.getElementById(txt).value 
= "afadfadfa";
__doPostBack(txt,'');
}

</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 192px; POSITION: absolute; TOP: 120px"
runat
="server" AutoPostBack="True"></asp:TextBox>
<br />
<button onclick="xx();">XX</button>
</form>
</body>
</HTML>

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace MyWap
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>

public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}

Web 窗体设计器生成的代码
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
Response.Write(
"TextBox1's Text Changed");
}

}

}

posted on 2007-11-20 11:18  simhare  阅读(4508)  评论(0)    收藏  举报

导航