ASP.NET 怎样给TextBox添加onkeyup事件并用来调用类
<form id="form1" runat="server"> <div> <asp:LinkButton ID="LinkButton1" Text="" runat="server" /> <asp:TextBox ID="shutdownRateTxB" runat="server" onkeyup='javascript:__doPostBack("shutdownRateTxB", "");' OnTextChanged="shutdownRateTxB_TextChanged1"></asp:TextBox> </div> </form>
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void shutdownRateTxB_TextChanged1(object sender, EventArgs e) { calcShutdownRate(); } }添点代码巧妙解决了,就是手动让它再次自动聚焦
protected void shutDownTimeTxB_TextChanged(object sender, EventArgs e)
{
calcShutdownRate();
shutDownTimeTxB.Focus();
}
<asp:TextBox ID="shutDownTimeTxB" runat="server"
onkeyup='javascript:__doPostBack("shutDownTimeTxB", "");'
ontextchanged="shutDownTimeTxB_TextChanged"
onfocus="cc()"></asp:TextBox>
function cc() {
var e = event.srcElement;
var r = e.createTextRange();
r.moveStart("character", e.value.length);
r.collapse(true);
r.select();
}