如何从asp.net按钮单击事件调用javascript函数
发布时间:2020-05-23 23:21:15 所属栏目:asp.Net 来源:互联网
导读:如何从asp.net按钮单击事件中调用showDialog.我的页面是一个内容页面,其中包含与之关联的母版页. 我尝试了以下内容 asp:Button ID=ButtonAdd runat=server Text=Add OnClientClick=showDialog(#addPerson); / asp:B
|
如何从asp.net按钮单击事件中调用showDialog.我的页面是一个内容页面,其中包含与之关联的母版页. 我尝试了以下内容 <asp:Button ID="ButtonAdd" runat="server" Text="Add"
OnClientClick="showDialog('#addPerson');" />
<asp:Button ID="ButtonAdd" runat="server" Text="Add"
OnClientClick="showDialog(#<%=addPerson.ClientID %>);" />
我还必须从gridview模板按钮调用此相同的函数来修改对话框中的记录. <script type="text/javascript">
// Used the following example to open the dialog withJquery
var dl;
$(document).ready(function () {
//Adding the event of opening the dialog from the asp.net add button.
//setup edit person dialog
$('#addPerson').dialog({
//Setting up the dialog properties.
show: "blind",hide: "fold",resizable: false,modal: true,height: 400,width: 700,title: "Add New Member",open: function (type,data) {
$(this).parent().appendTo("form:first");
}
});
//setup edit person dialog
$('#editPerson').dialog({
//Setting up the dialog properties.
show: "blind",title: "Modify Member",data) {
$(this).parent().appendTo("form");
}
});
function showDialog(id) {
$('#' + id).dialog("open");
}
// function closeDialog(id) {
// $('#' + id).dialog("close");
// }
//Adding a event handler for the close button that will close the dialog
$("a[id*=ButtonCloseDlg]").click(function (e) {
$("#divDlg").dialog("close");
return false;
});
});
</script>
试图从gridview编辑按钮调用jquery对话框并获得相同的错误对象不支持此属性或方法? <input type="submit" name="ctl00$ContentPlaceHolder1$GridViewMembers$ctl02$Button1" value="Edit" onclick="showDialog('addPerson');" id="ContentPlaceHolder1_GridViewMembers_Button1_0" /> 解决方法如果按下此按钮时不需要发回帖子,则无需进行服务器控件的开销.<input id="addButton" type="button" value="Add" />
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
$('#addButton').click(function()
{
showDialog('#addPerson');
});
});
</script>
如果您仍然需要能够回发,您可以使用一些不同的代码有条件地停止其余的按钮操作: <asp:Button ID="buttonAdd" runat="server" Text="Add" />
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
$('#<%= buttonAdd.ClientID %>').click(function(e)
{
showDialog('#addPerson');
if(/*Some Condition Is Not Met*/)
return false;
});
});
</script> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net读取excel文件的三种方法示例
- asp.net gridview:如何在一列中包含多个按钮字段?
- asp.net – 菜单控件生成的js导致Web窗体中的Sys未定义的异
- asp.net – HttpContext.Error vs HttpContext.Server.GetL
- 将数据从asp.net-mvc传递到javascript的最佳做法
- asp.net – 在本地主机上开发Facebook Connect Javascript
- ASP.NET中的%%(嵌入式代码块)
- asp.net-mvc – web.config中的表单身份验证
- 在ASP.Net Web应用程序中运行后台任务并获得反馈的最佳方法
- asp.net-web-api – 从ASP.NET Web API ASP.NET Core 2返回
推荐文章
站长推荐
- asp.net-mvc – AspNet Identity 2.0电子邮件和用
- asp.net-core – 更改Asp.net Core中静态文件的标
- asp.net – 有没有办法以编程方式添加项目到元素
- ASP.Net Response.Redirect不能在Application_Er
- asp.net-core – 如何使用带有IdentityServer4的
- asp.net-mvc – ASP.NET MVC 4邮政编码验证
- asp.net – NullReferenceException在PipelineSt
- 为什么[System.ComponentModel.ToolboxItem(fals
- asp.net – Oracle.ManagedDataAccess:TNS:无法
- Asp.net超链接控件相当于
热点阅读
