asp.net中前台javascript调用后台的按钮事件。坐待指教
asp.net中前台javascript调用后台的按钮事件。。。。急啊,坐等指教。
我要的效果其实是让前台的标签有点击事件,可以写后台代码!
前台代码
<script src="JScript.js" type="text/javascript"></script>
</head>
<body style="height: 598px">
<form id="form1" runat="server">
<div id="11" onclick="qs()" style="height: 226px; width: 222px">
123456
</div>
<asp:Button ID="Button1" runat="server" Height="29px" onclick="Button1_Click"
Text="Button" />
</form>
</body>
</html>
通过div的点击调用javascript函数
function qs() {
document.getElementById("Button1").click();
}
用javascript函数触发后台服务器控件Button1的事件,没有报错,但是当我把button1的visible设为false后,就变成了这样:

------解决思路----------------------
后台设置
opSQProcessing.Attributes.Add("style","display:none;");
而不是设置它的visiable为false
------解决思路----------------------
额错了。你禁用了。需要开启才能使用。上面代码就不对了。
在 document.getElementById("Button1").click();前面把buttom 解除禁用。
document.getElementById("Button1").removeAttribute("disabled");
参考http://blog.****.net/love_rrr/article/details/4917246
我要的效果其实是让前台的标签有点击事件,可以写后台代码!
前台代码
<script src="JScript.js" type="text/javascript"></script>
</head>
<body style="height: 598px">
<form id="form1" runat="server">
<div id="11" onclick="qs()" style="height: 226px; width: 222px">
123456
</div>
<asp:Button ID="Button1" runat="server" Height="29px" onclick="Button1_Click"
Text="Button" />
</form>
</body>
</html>
通过div的点击调用javascript函数
function qs() {
document.getElementById("Button1").click();
}
用javascript函数触发后台服务器控件Button1的事件,没有报错,但是当我把button1的visible设为false后,就变成了这样:
------解决思路----------------------
后台设置
opSQProcessing.Attributes.Add("style","display:none;");
而不是设置它的visiable为false
------解决思路----------------------
额错了。你禁用了。需要开启才能使用。上面代码就不对了。
在 document.getElementById("Button1").click();前面把buttom 解除禁用。
document.getElementById("Button1").removeAttribute("disabled");
参考http://blog.****.net/love_rrr/article/details/4917246