button的onclick事件和onclientclick事件的执行顺序是什么样的呀?
我做的相册管理系统,创建相册时是通过点击“创建相册按钮”,然后弹出创建相册的隐藏层,填好相册信息后点击确定按钮完成创建。确定按钮有onclick事件和onclientclick事件,onclientclick事件使得弹出的隐藏层再次隐藏,onclick事件在后台完成相册的创建。现在无法执行onclick事件,我怀疑是因为先执行了onclientclick事件,使得隐藏层隐藏了,就没有触发onclick事件。(因为我把隐藏层display:none去掉了,再点击确定,就触发onclick事件,在后台完成相册的创建。)下面是我的相关代码。
//onclick事件
protected void btnCreate_Click(object sender, EventArgs e)//创建相册,未写
{
albummanage.Name = Txt_name.Value;
if (pre1.Checked)
{
albummanage.Purview = "仅自己可见";
}
else
{
albummanage.Purview = "公开";
}
albummanage.Id = albummanage.GetAlbumID();
albummanage.Cover = "image/moren.PNG";//用户没有自己设定封面时,默认一个
albummanage.Createtime = DateTime.Now; usermanage.Name = "xiaonan";//先写死
//username.InnerText = (string)Session["Name"];
DataRow row = UserInfo(usermanage); albummanage.Creator = (string)row["id"];
albummanage.AddAlbum(albummanage);
}
//创建相册的隐藏层
<div id="createForm" style="display:none; border:1px solid red ">
<table style ="width:350px;height :200px">
<tr style ="width :auto;">
<td style="width: 116px;" >
<font size="2" color="blue"> 创建相册</font>
</td>
<td style="height: 19px;">
<img id="close" alt="" src="image/关闭.PNG" style="float :right"/>
</td>
</tr>
<tr>
<td style="width: 116px;">
<font size="2" color="blue"> 相册名称:</font>
</td>
<td style="height: 47px;width: 185px;">
<input type="text" id="Txt_name" runat="server" />
</td>
</tr>
<tr>
<td style="width: 116px;">
<font size="2" color="blue"> 相册权限:</font>
</td>
<td style="height: 39px;">
<input type="radio" name="purview" value ="自己可见" id="pre1" runat="server"/>自己可见
<input type="radio" name="purview" value ="所有人可见" id="pre2" runat="server"/>所有人可见
</td>
</tr>
<tr>
<td align="right" style="width: 116px;">
<asp:Button ID="btnCreate" runat="server" Text="确定" OnClick="btnCreate_Click"
OnClientClick="ClientClick()" />
</td>
<td align="center" style="height: 42px;">
<input id="btnCancel" type="button" value="取消" />
</td>
</tr>
</table>
</div>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="jquery%20blockui/jquery.blockUI.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#myPhoto").css("background", "red"); $("#create").click(function () {
$.blockUI({
message: $("#createForm"),
css: {
width: '350px',
height: '200px',
left: ($(window).width()) / 2 + 'px',
top: ($(window).height()) / 2 + 'px', border: 'none'
}
});
});// $("#btnCreate").click(function () {// alert("相册创建成功!");// setTimeout(function () { $.unblockUI() }, 1000);
// // });
$("#btnCancel").click(function () {
$.unblockUI();
}); $("#close").click(function () {
$.unblockUI();
});
});
function ClientClick() {
alert("相册创建成功!"); setTimeout(function () { $.unblockUI() }, 1000);
}
asp.net button按钮
我做的相册管理系统,创建相册时是通过点击“创建相册按钮”,然后弹出创建相册的隐藏层,填好相册信息后点击确定按钮完成创建。确定按钮有onclick事件和onclientclick事件,onclientclick事件使得弹出的隐藏层再次隐藏,onclick事件在后台完成相册的创建。现在无法执行onclick事件,我怀疑是因为先执行了onclientclick事件,使得隐藏层隐藏了,就没有触发onclick事件。(因为我把隐藏层display:none去掉了,再点击确定,就触发onclick事件,在后台完成相册的创建。)下面是我的相关代码。
//onclick事件
protected void btnCreate_Click(object sender, EventArgs e)//创建相册,未写
{
albummanage.Name = Txt_name.Value;
if (pre1.Checked)
{
albummanage.Purview = "仅自己可见";
}
else
{
albummanage.Purview = "公开";
}
albummanage.Id = albummanage.GetAlbumID();
albummanage.Cover = "image/moren.PNG";//用户没有自己设定封面时,默认一个
albummanage.Createtime = DateTime.Now; usermanage.Name = "xiaonan";//先写死
//username.InnerText = (string)Session["Name"];
DataRow row = UserInfo(usermanage); albummanage.Creator = (string)row["id"];
albummanage.AddAlbum(albummanage);
}
//创建相册的隐藏层
<div id="createForm" style="display:none; border:1px solid red ">
<table style ="width:350px;height :200px">
<tr style ="width :auto;">
<td style="width: 116px;" >
<font size="2" color="blue"> 创建相册</font>
</td>
<td style="height: 19px;">
<img id="close" alt="" src="image/关闭.PNG" style="float :right"/>
</td>
</tr>
<tr>
<td style="width: 116px;">
<font size="2" color="blue"> 相册名称:</font>
</td>
<td style="height: 47px;width: 185px;">
<input type="text" id="Txt_name" runat="server" />
</td>
</tr>
<tr>
<td style="width: 116px;">
<font size="2" color="blue"> 相册权限:</font>
</td>
<td style="height: 39px;">
<input type="radio" name="purview" value ="自己可见" id="pre1" runat="server"/>自己可见
<input type="radio" name="purview" value ="所有人可见" id="pre2" runat="server"/>所有人可见
</td>
</tr>
<tr>
<td align="right" style="width: 116px;">
<asp:Button ID="btnCreate" runat="server" Text="确定" OnClick="btnCreate_Click"
OnClientClick="ClientClick()" />
</td>
<td align="center" style="height: 42px;">
<input id="btnCancel" type="button" value="取消" />
</td>
</tr>
</table>
</div>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="jquery%20blockui/jquery.blockUI.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#myPhoto").css("background", "red"); $("#create").click(function () {
$.blockUI({
message: $("#createForm"),
css: {
width: '350px',
height: '200px',
left: ($(window).width()) / 2 + 'px',
top: ($(window).height()) / 2 + 'px', border: 'none'
}
});
});// $("#btnCreate").click(function () {// alert("相册创建成功!");// setTimeout(function () { $.unblockUI() }, 1000);
// // });
$("#btnCancel").click(function () {
$.unblockUI();
}); $("#close").click(function () {
$.unblockUI();
});
});
function ClientClick() {
alert("相册创建成功!"); setTimeout(function () { $.unblockUI() }, 1000);
}
asp.net button按钮
解决方案 »
- 基类包括字段“page”,但其类型(System.Web.UI.Page)与控件(System.Web.UI.WebControls.DropDownList)
- 急 在线等
- 如何在aspx页面中从根下面引用一个静态文件?
- .net里引用对象的问题
- 求下拉框连动代码
- 为什么代码在前台
- 急问如何在treeview中实现鼠标右键功能,VB的,有例子最好,100分奉送
- 那位高手帮我解释一下window.open(location,'newwindow','toolbar=no,scrollbars=yes,resizable=no,top=0,left=0,width=300,height=300')
- ***********************请教一个关于IDisposable接口实现的问题***************
- 公共问题????
- GridView1.DataSource = dt;dt包含内容,代码运行到此行,跳出
- using ExtensionMethods; asp.net 4.0 报错
UseSubmitBehavior="False" onclick="Button1_Click" OnClientClick="ClientClick()" /> function ClientClick() {
jQuery("#Button1").hide();
alert("客户端事件!");
}不会啊,你试加UseSubmitBehavior="False"试试看
服务端:OnClick 后
....
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "dd",
"<script>ClientClick();</script>");
}
你想这样?