如题
解决方案 »
- 最不常用的标点符号有哪些
- 在win7的iis7.5上部署asp.net的一个教务管理系统时遇到了写问题(在线等)
- 三层里逻辑工厂里不明白地方求教!!
- VS03升级到05,session保存用户控件造成控件事件丢失的问题
- 能不能在.CS控制HTML控件里的INPUTBUTTON可用不可用?
- ★★★请思归、孟子E章等高手帮个忙!★★★
- 一个关于cookies的问题,急!!!
- 小弟求教水晶报表的问题!
- 在asp.net中如何验证让用户密码必须输入4位以上数字或字母??
- 我想要在dATAGRID里,用一个IMAGBUTTON激发一个存储工程
- ASP.NET 的 C#代码里有这样一个语句
- 页面超时的问题。。。。。
支持粘贴操作
function thisFunc(this)
{
if(event.keyCode!='13'&&event.keyCode!='9')
{
__doPostBack(this.id,'','');
}
}page_load时:添加函数page.registerClientScriptBlock("",thisTextBox.ClientID + ".focus();")
你所说的那个控件是html控件,在C#程序里面怎么进行操作呀
你所说的那个控件是html控件,在C#程序里面怎么进行操作呀//==>
在客户端生成的也是html control
cs:
Textbox1.Attributes["onpropertychange"] = "thisFunc(this)";javascript:
function thisFunc(this)
{
__doPostBack(this.id,'','');
}如果还想在TextChange事件(PostBack)后文本框还需要获取焦点, 就在TextBox的TextChange事件里加一句
Page.RegisterStartupScript("", "<script>javascript:document.all.txtID.focus();</script>");
现在可以触发了,但是焦点是停在textbox的最前,我如果要它停在textbox的最后面怎么办呀
Page.RegisterStartupScript("go","<script language="javascript">NewFocus(document.all.thisTextBox)</script>")页面上加上
<script language = "javascript">
function NewFocus(TextBox)
{
TextBox.focus();
var oTextRange = document.createTextRange();
oTextRange.collapse(false);
oTextRange.select();
}这样就可以将光标定位到末尾了。
</script>
function NewFocus(TextBox)
{
TextBox.focus();
var oTextRange = TextBox.createTextRange();
oTextRange.collapse(false);
oTextRange.select();
}
function thisFunc(this)
{
if(event.keyCode==32||(event.keyCode>48&&event.keyCode<90))
{
__doPostBack(this.id,'','');
}
}
不然你会烦死的,移动光标都会回发。
为什么我写进去以后不行呀,老是提示缺少对象。在 TextBox.focus();这行
<HTML>
<HEAD>
<TITLE></TITLE>
<META content="Microsoft Visual Studio 7.0" name="GENERATOR">
<SCRIPT ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
var index;
function window_onload() {
div1.style.left=Text1.offsetLeft;
div1.style.top=Text1.offsetTop+24;
div1.style.width=Text1.offsetWidth;
index=0;
}function Text1_onkeyup()
{
switch (window.event.keyCode)
{
case 13:
div1.style.visibility="hidden";
break;
case 40:
case 39:
if (index < div1.childNodes.length)
{
index=index+1;
}
for (i=1;i<=div1.childNodes.length;i++)
{
if (i==index)
{
Text1.value=div1.childNodes[index-1].innerText.substr(1);
div1.childNodes[index-1].style.backgroundColor="lightblue";
}
else
{
div1.childNodes[i-1].style.backgroundColor="white";
}
}
break;
case 38:
case 37:
if (index>1)
{
index=index-1;
}
for (i=1;i<=div1.childNodes.length;i++)
{
if (i==index)
{
Text1.value=div1.childNodes[index-1].innerText.substr(1);
div1.childNodes[index-1].style.backgroundColor="lightblue";
}
else
{
div1.childNodes[i-1].style.backgroundColor="white";
}
}
break;
default:
index=0;
div1.innerHtml ="";
docSubmit = new ActiveXObject("MSXML2.DOMDocument");
docSubmit.async = false;
docSubmit.load("http://msft-chen/ASPTips2/CH1/SearchTitles.asmx/doSearch?keyword=" + Text1.value);
docSubmit.loadXML(docSubmit.xml.replace(/</g,"<").replace(/>/g,">"));
//
var s;
s="";
nodeList=docSubmit.documentElement.getElementsByTagName("Table");
for (i=0;i<nodeList.length;i++)
{
s=s + "<div style=\"WIDTH:490px;\" class=\"gotTitle\" onmouseover=\"javascript:this.style.backgroundColor='lightblue'\" onmouseout=\"javascript:this.style.backgroundColor='white'\" onclick=\"return gotTitle_onclick()\"> " + nodeList(i).selectSingleNode("title").text + "</div>";
}
div1.innerHTML=s;
div1.style.visibility="visible";
}
}function gotTitle_onclick()
{
if (window.event.srcElement.className="gotTitle")
{
Text1.value=window.event.srcElement.innerText.substr(1);
div1.style.visibility="hidden";
}
}function gotTitle_onblur()
{
div1.style.visibility="hidden";
}//-->
</SCRIPT>
<style> .list{ BORDER-RIGHT:black 1px solid; BORDER-TOP:black 1px outset; BORDER-BOTTOM:black 1px solid; BORDER-LEFT:black 1px outset; FONT-SIZE:x-small; VISIBILITY:hidden; WIDTH:490px; HEIGHT:20px; CURSOR:default; POSITION:absolute; }
</style>
</HEAD>
<BODY LANGUAGE="javascript" onload="return window_onload()">
<P><FONT face="宋体">搜索图书:</FONT> <INPUT id="Text1" type="text" name="Text1" size="78" LANGUAGE="javascript" onkeyup="return Text1_onkeyup()"> </P>
<span id="div1" onblur="return gotTitle_onblur()" class="list"></span>
<P><FONT face="宋体"></FONT></P>
</BODY>
</HTML>