📄 webusercontrol1.ascx
字号:
<%@ Control Language="c#" Inherits="System.Web.UI.UserControl" ClassName="WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<script language="C#" runat="server">
public System.Reflection.MethodInfo method = null;
private void Page_Load(object sender, System.EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(WebUserControl1), this.Page);
}
[AjaxPro.AjaxMethod]
public int GetLength(string s)
{
return s.Length;
}
</script>
<script type="text/javascript">
var textLen = Class.create();
textLen.prototype = {
initialize: function(ele) {
this.timer = null;
this.ele = ele;
this.display = document.getElementById(this.ele.id + "_display");
addEvent(this.ele, "keyup", this.dosearch.bind(this));
},
dosearch: function() {
if(this.timer != null) clearTimeout(this.timer);
this.timer = setTimeout(this.dosearch_next.bind(this), 100);
},
dosearch_next: function() {
ASP.WebUserControl1.GetLength(this.ele.value, this.ondata.bind(this));
},
ondata: function(res) {
this.display.innerHTML = res.value;
}
};
function init() {
var x = new textLen(document.getElementById("<%=ClientID%>"));
x.ele.focus();
}
addEvent(window, "load", init);
</script>
<input type="text" id="<%=ClientID%>"/>
<div>Length of the string: <span id="<%=ClientID%>_display">0</span></div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -