我有啓動在編輯模式,並允許用戶從下拉菜單中選擇是或否,然後按下「保存」按鈕,這是Formviews更新命令一個FormView:ASP.net射擊jQuery的ASP後UPDATE
<asp:FormView ID="FormView1" runat="server" DataSourceID="CustomerEdit">
<ItemTemplate>
hello
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="CustomerNameLabel2" runat="server"
Text='<%# Bind("CustomerName") %>' />
<asp:Label ID="CustID" runat="server" visible="false"
Text='<%# Bind("CustID") %>' />
<br>
<br></br>
Is This Your Customer?
<br>
<br>
<asp:DropDownList ID="DropDownList1" runat="server"
SelectedValue='<%# Bind("IsThisMyCustomer") %>'>
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:DropDownList>
<br>
<br>
<asp:Button ID="Button" runat="server" CausesValidation="True"
CommandName="Update" Text="Save" />
</EditItemTemplate>
</asp:FormView>
此按鈕也有JQuery的背後
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<script>
$(document).ready(function() {
$("input[id$='Button']").click(function() {
var div = $("div");
$("img").hide();
div.animate({ height: '300px', opacity: '0.4' }, "slow");
div.animate({ width: '300px', opacity: '0.8' }, "slow", function() {
window.location.href = "MyCustomers.aspx";
});
});
});
</script>
現在,當用戶點擊該按鈕時,jQuery腳本通過jQuery腳本,通過FormView控件更新指令踢的SQL更新的動畫踢,然後大約一半從本質上阻止了jquery從事它的工作和啓動根據定期更新來調用formview的itemtemplate。
我想要的是發生和回發的SQL更新,然後jquery會直接觸發。
這樣做的最佳方法
您似乎混淆了客戶端和服務器端的功能。發生回發時,JavaScript會被完全卸載,然後在頁面再次呈現時再次從頭開始加載。如果您想在回發後從JavaScript中發生某些事情,那麼在頁面重新呈現時需要發生。也許包括JavaScript來從服務器端事件處理程序執行此操作。而是''click'事件直接發生在'ready'事件中呢?它似乎不適合理想的UX,重新加載一個頁面*只是*重定向到另一個頁面。 – David 2014-11-14 14:52:56
我很困惑大衛。好的 - 那麼如何設置jquery在點擊該按鈕後回發後運行?我編輯jquery到這個; $(window).load(function(){ $(document).ready(function(){它使它通過一個不斷的動畫循環:) – user3294008 2014-11-14 15:04:41