母版页:我在母版页中使用了jquery 1.5,在子页面中使用了1.7,1.8
<script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="../js/hideshow.js" type="text/javascript"></script>
<script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>`enter code here`
<script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".tablesorter").tablesorter();
}
);
子页面javascript:在这个ADD函数中没有调用
<script type="text/javascript">
$("[id*=btnadd]").live("click", function () {
debugger;
$("#modal_dialog").dialog({
title: "Manage Branch",
autoopen: false,
width: 500,
buttons: {
ADD: function () {
$("[id*=add]").click();
},
Cancel: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
<div id="modal_dialog" style="display: none">
<div class="tab_container">
<div id="tab2" class="tab_content">
<table class="tablesorter" cellspacing="0">
<tbody>
<tr>
<td>
<b>ID:
<asp:TextBox ID="TextBox1" runat="server" Style="margin-left: 130px"></asp:TextBox>
<br />
<br />
Branch:
<asp:TextBox ID="TextBox2" runat="server" Style="margin-left: 97px"></asp:TextBox>
<br />
<br />
</td>
</tr>
</tbody>
<asp:Button ID="add" runat="server" Text="ADD" style="display:none" OnClick="btninsert_Click"></asp:Button>
</table>
<%-- <asp:Button ID="Button1" runat="server" Text="Button" style = "display:none" OnClick = "Button_Click"/>--%>
</div>
<!-- end of #tab1 -->
</div>
<!-- ID -->
</div>
调用功能:单击“添加”按钮时,此功能必须调用
protected void btninsert_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=WINCTRL-TNT3FMR;Initial Catalog=TaxiAPP;Integrated Security=True";
SqlCommand command = new SqlCommand("Insert into Branch(ID,Branch)values(@ID,@Branch)SELECT SCOPE_IDENTITY()", con);
con.Open();
command.Parameters.AddWithValue("@ID", TextBox1.Text);
command.Parameters.AddWithValue("@Branch", TextBox2.Text);
command.ExecuteNonQuery();
con.Close();
}
答案 0 :(得分:0)
请替换这两个代码并尝试,希望这会有效,
<script type="text/javascript">
$(document).ready(function () {
$(".tablesorter").tablesorter();
});
</script>
和
<script type="text/javascript">
$(document).on("click", "[id*=btnadd]", function () {
debugger;
$("#modal_dialog").dialog({
title: "Manage Branch",
autoopen: false,
width: 500,
buttons: {
ADD: function () {
$("[id*=add]").click();
},
Cancel: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
</script>