62,243
社区成员




function txtonfocus() {
var txt = document.getElementById("txtSearch");
txt.vaklue = "123";
}
<asp:TextBox ID="TextBox1" Name="111" runat="server" onfocus="txtOnfocus()"></asp:TextBox>
<script language="javascript" type="text/javascript">
function txtOnfocus() {
document.getElementById("<%=this.TextBox1.ClientID %>").onfocus = function () { this.value = "123"; };
}
</script>
<input type="text" name="txt1" id="txt1"/>
document.getElementById("txtSearch").value;
<script language="javascript" type="text/javascript">
function txtOnfocus() {
document.getElementById("txt1").onfocus = function () { this.value = "123"; };
}
</script>
<input type="text" name="txt1" id="txt1"/>
<head runat="server">
<title>无标题页</title>
<script type="text/ecmascript">
function txtonfocus()
{
var t=document.getElementById("<%=this.txtSearch.ClientID%>");
t.value="123";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox></div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.txtSearch.Attributes.Add("onfocus", "txtonfocus()");
}
}
<head runat="server">
<title>无标题页</title>
<script type="text/ecmascript">
function txtonfocus()
{
var t=document.getElementById("<%=this.txtSearch.ClientID%>");
t.value="123";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox></div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.txtSearch.Attributes.Add("onfocus", "txtonfocus()");
}
}
<%@ 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>
<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>
</div>
</form>
<script>
document.getElementById("<%= txtSearch.ClientID %>").onfocus = function () {
this.value = "123";
}
</script>
</body>
</html>
<head runat="server">
<title>无标题页</title>
<script type="text/ecmascript">
function txtonfocus()
{
var t=document.getElementById("txtSearch");
t.value="123";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type=text id="txtSearch" onfocus="txtonfocus()" />
</div>
</form>
</body>
</html>