js控制DIV彈出層中服務器按鈕事件失效 htmljsc# 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有看到你alertWin()你在页面中调用这个js方法啊服务器控件中用onclientclick调用js方法 onclick响应后台事件 已經調用 彈出層也沒有問題 代碼如下<input type="button" class="button gray" value="錄入" onclick="viewWin()" />function viewWin() { alertWin("MVI手動資料錄入", "divWIN", 700, 200); //getCompleteData('icachtr_keyin_jkzlwh.aspx/getCurTypeList', '', '<%=txtInvoiceNO.ClientID %>', '3', 250); }現在的關鍵問題是 服務器的button一旦到顯示層時候 點擊按鈕就不響應服務器事件了 +1 onclientclick 事件的返回值要保证为true才能执行服务端事件。 +1 onclientclick 事件的返回值要保证为true才能执行服务端事件。两个结合在一起就ok了 +1 onclientclick 事件的返回值要保证为true才能执行服务端事件。问题的纠结点不在这里 我点击录入调用 alertWin事件 没有问题 我的意思是我div放的服务器控件绑定了code代码事件 作为弹出层时候这个保存按钮的点击事件就失效了 这个才是问题的关键 大神们 弹出层这里调用没有问题只是没贴全代码 看图片 点击录入时候 把body中一个div作为弹出层时候 div中服务器控件绑定的code代码事件失效了 求教什么原因 该怎么做 。。看来我的语文是体育老师教的 表达能力太差 让大家误解了 用回调函数,返回true的时候执行后台事件。 这样貌似不可以的。服务器控件添加一个onclientclick=‘test()'; function test(){ $('#btnId').click();} csdn這就沒人了 算了 自己想辦法 ... function test(){ $('#btnId').click();} 对应服务器控件ID function test(){ $('#btnApply').click();}不行的话也可以js中ajax异步执行,效率还高些。 我还不至于那么笨 肯定是对应的服务器控件ID 单还是报这个错误 不明白你这个原理 test()方法中调用按钮click事件 这样不是死循环码?跟服务器没有任何关系啊另:jquery的ajax调用后台方法 不是只能调用静态方法吗? 快整无语了 我猜测是appendchild方法问题,该方法把 服务器控件自动编译成html控件了 求解 我还不至于那么笨 肯定是对应的服务器控件ID 单还是报这个错误 不明白你这个原理 test()方法中调用按钮click事件 这样不是死循环码?跟服务器没有任何关系啊另:jquery的ajax调用后台方法 不是只能调用静态方法吗? 快整无语了 我猜测是appendchild方法问题,该方法把 服务器控件自动编译成html控件了 求解ajax直接建一个处理过程页面就好了,还有服务器控件在弹出层的时候是被加载到form外层的,因此不能点击的时候不能触发 前台代码<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> #showdiv { width: 200px; height: 200px; z-index: 10; border: 2px solid #000; display:none ; background-color:#808080; position:absolute; } </style> <script src="jquery-1.9.0.js" type="text/jscript"></script> <script type="text/jscript"> $(function () { $('#btntt').click(function () { $('#showdiv').show(); }); }); </script></head><body> <form id="form1" runat="server"> <div id="showdiv"> 我是弹出层 <asp:Button ID="Button1" runat="server" Text="我是后台按钮" OnClick="Button1_Click" /> </div> <div> <input type="button" id="btntt" value="点我弹出" /> </div> </form></body></html>后台代码using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('我是后台代码!执行完毕!');$('#showdiv').hide();</script>"); } }}这个例子在我这行,你试试 C#中怎样从一个窗口自动跳到另一个窗口 请问,这个线程,为什么输出不一样 求助:C#调用ocx文件的问题 高手请进!!C#提示问题 100分求解决办法?大家帮忙 聊天窗口发送表情功能 如何点击按钮动态增加一个label 如何设定DataGrid每一列的宽度? 如何锁定窗体或鼠标?Winform C#IEnumrator<T> 懂JS 代码的帮我转一下这断BASE64代码,转成C#的 实现多条件查询
onclick响应后台事件
已經調用 彈出層也沒有問題 代碼如下
<input type="button" class="button gray" value="錄入" onclick="viewWin()" />
function viewWin() {
alertWin("MVI手動資料錄入", "divWIN", 700, 200);
//getCompleteData('icachtr_keyin_jkzlwh.aspx/getCurTypeList', '', '<%=txtInvoiceNO.ClientID %>', '3', 250);
}
現在的關鍵問題是 服務器的button一旦到顯示層時候 點擊按鈕就不響應服務器事件了
问题的纠结点不在这里 我点击录入调用 alertWin事件 没有问题 我的意思是我div放的服务器控件绑定了code代码事件 作为弹出层时候这个保存按钮的点击事件就失效了 这个才是问题的关键
看来我的语文是体育老师教的 表达能力太差 让大家误解了
服务器控件添加一个onclientclick=‘test()';
function test()
{
$('#btnId').click();
}
...
function test()
{
$('#btnId').click();
}
function test()
{
$('#btnApply').click();
}
不行的话也可以js中ajax异步执行,效率还高些。
还有服务器控件在弹出层的时候是被加载到form外层的,因此不能点击的时候不能触发
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
#showdiv {
width: 200px;
height: 200px;
z-index: 10;
border: 2px solid #000;
display:none ;
background-color:#808080;
position:absolute;
}
</style>
<script src="jquery-1.9.0.js" type="text/jscript"></script>
<script type="text/jscript">
$(function () {
$('#btntt').click(function () {
$('#showdiv').show();
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="showdiv">
我是弹出层
<asp:Button ID="Button1" runat="server" Text="我是后台按钮" OnClick="Button1_Click" />
</div>
<div>
<input type="button" id="btntt" value="点我弹出" />
</div>
</form>
</body>
</html>后台代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('我是后台代码!执行完毕!');$('#showdiv').hide();</script>");
}
}
}这个例子在我这行,你试试