Response.Write("<script>function dis(this)</script>");这是我叫前台的JS方法 不知道对不对
前台方法是:
function dis(b) {
document.getElementById('DivCustomerIncomeTbl').style.display = (document.getElementById('DivCustomerIncomeTbl').style.display == "block") ? "none" : "block";
b.value = (b.value == "显示") ? "隐藏" : "显示";
} 这样不行!· 还请大家帮下忙!·
前台方法是:
function dis(b) {
document.getElementById('DivCustomerIncomeTbl').style.display = (document.getElementById('DivCustomerIncomeTbl').style.display == "block") ? "none" : "block";
b.value = (b.value == "显示") ? "隐藏" : "显示";
} 这样不行!· 还请大家帮下忙!·
在CheckBox的CheckedChanged事件里面写
if (chk_Invoice_Flg.Checked == true){调用JS方法显示Div}
else{调用JS方法关闭Div}
我要做的就是这样效果! 希望大家提提意见!或帮忙给个实列!
这样写 可以吗? 没试过,明天早上试下Response.Write(" <script>alert('aaa')</script>");
这样写,只能调用JS本身函数,不可调 自定义的哦ScriptManager.RegisterStartupScript(this, this.GetType(), "", "JS('"+param1+"','"+param2+"')", true);
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function dis(b) {
if (b.value == "显示") {
$get('DivCustomerIncomeTbl').style.display = 'block';
$get('DivCustomerIncomeTbl').style.left = event.x + 'px';
$get('DivCustomerIncomeTbl').style.top = event.y + 'px';
b.value = "隐藏";
}
else {
$get('DivCustomerIncomeTbl').style.display = 'none';
b.value = "显示";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<input type="button" value="显示" onclick="dis(this)" />
<div id="DivCustomerIncomeTbl" style="border:solid 1px Black;width: 300px; height:300px; display:none; position:absolute;z-index:999; background-color:Maroon;">
</div>
</form>
</body>
</html>
还不如把它作为服务器控件在后台用visible
你这么输出不对,应该是Response.Write(" <script>dis(值)</script>");
但是response.write输出的值会是在前台页面中优选输出的,也就是说你这调用会在脚本加载完之前就调用,这就造成调用的时候对象不存在,你应该先用response.write输出脚本,或者用函数Sub dis() 然后在需要调用的地方用<%dis%>!