TextBox內容發生改變時觸發的事件
阿新 • • 發佈:2019-02-09
方法一:不推薦
1. 前臺textbox屬性AutoPostBack="true";
2.後臺
protected void Page_Init(object sender, EventArgs e)
{
txtVehicleNum.TextChanged += new EventHandler(txtVehicleNum_TextChanged);
}
void txtVehicleNum_TextChanged(object sender, EventArgs e) { DangerClassDataBind(); }
方法二:不推薦
1.後臺
protected void Page_Init(object sender, EventArgs e)
{
txtVehicleNum.Attributes["OnBlur"] = ClientScript.GetPostBackEventReference(btnTemp, null);
}
方法三:推薦void btnTemp_Click(object sender, EventArgs e) { DangerClassDataBind(); }
1.js:
2.後臺//選擇車輛 function openSelectVehicleWindow() { var returnValue = window.showModalDialog("VehicleInfo_Select.aspx", window, "dialogWidth:1000px; dialogHeight:500px; status:no; directories:yes;scrollbars:no;Resizable=no;help=no"); if (returnValue != null) { var strvalue = returnValue.split('|'); document.getElementById("<%=txtVehicleNum.ClientID %>").value = strvalue[0]; document.getElementById("<%=txtPlateColor.ClientID %>").value = strvalue[1]; document.getElementById("<%=txtPlateColorName.ClientID %>").value = strvalue[2]; document.getElementById("btnTemp").click(); } }
void btnTemp_Click(object sender, EventArgs e)
{
DangerClassDataBind();
}