问题描述
前台:<scripttype="text/javascript"language="javascript">functiongetOrg(ReturnTxt){document.getElementById("txtOrg").value=ReturnTxt.substring(0,ReturnTxt.indexOf(','));document.getElementById("HiddenOrgID").value=ReturnTxt.substring(ReturnTxt.indexOf(',')+1);}</script><asp:TextBoxID="txtOrg"runat="server"Width="200px"ReadOnly="True"ontextchanged="txtOrg_TextChanged"AutoPostBack="True"></asp:TextBox><buttononclick="showPopWin('TEST','TreeDeptList_Radio.aspx',300,300,getOrg,true,true);"style="height:22px;">...</button><inputid="HiddenOrgID"runat="server"type="hidden"/>后台:protectedvoidtxtOrg_TextChanged(objectsender,EventArgse){}如何触发?
解决方案
解决方案二:
给你写个例子:<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%><!DOCTYPEhtml><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title></head><body><formid="form1"runat="server"><asp:TextBoxID="TextBox1"runat="server"OnTextChanged="TextBox1_TextChanged"></asp:TextBox></form><buttononclick="abc();">...</button></body></html>
usingSystem;usingSystem.Web.UI;publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){varscp=this.ClientScript.GetPostBackEventReference(this,string.Empty);ScriptManager.RegisterStartupScript(this,typeof(Page),"initabc","functionabc(){"+scp+";};",true);}protectedvoidTextBox1_TextChanged(objectsender,EventArgse){varx=TextBox1.Text;}}
解决方案三:
这里如果在招聘时要考察,就是一个问题:请说出GetPostBackEventReference函数机制。
解决方案四:
我一般放置一个button,点button来调用后台
解决方案五:
asp.netbutton服务器控件为什么能够回发到后台呢?
解决方案六:
sp1234,谢谢啊,不过没懂你意思,<buttononclick="abc();">我的意思是:abc()是js脚本,然后在js脚本中触发(调用)TextBox1_TextChanged事件
解决方案七:
sp1234,还能再详细的帮解答下吗?
解决方案八:
<scripttype="text/javascript"language="javascript">functiongetOrg(ReturnTxt){document.getElementById("txtOrg").value=ReturnTxt.substring(0,ReturnTxt.indexOf(','));document.getElementById("HiddenOrgID").value=ReturnTxt.substring(ReturnTxt.indexOf(',')+1);document.getElementById("txtOrg").onchange();}</script>
TextBoxAutoPostBack="True"会生成JS脚本,附加事件,只要调用onchange()即可回发
解决方案九:
<scripttype="text/javascript"language="javascript">functiongetOrg(ReturnTxt){document.getElementById("txtOrg").value=ReturnTxt.substring(0,ReturnTxt.indexOf(','));document.getElementById("HiddenOrgID").value=ReturnTxt.substring(ReturnTxt.indexOf(',')+1);document.getElementById("txtOrg").onchange();}</script>
解决方案十:
进来学习一下
解决方案十一:
$("id").bind("change",function(){//方法});