我有一個jQuery UI界面,有一組文本框和一個圖片上傳器。香港專業教育學院得到它和運行良好,但有一個問題與圖像上傳。停止jquery ui窗口從回發後關閉
當用戶點擊上傳他們的圖片時,代碼會自動啓動,但會在回發到同一頁面後返回,但顯示爲平面頁面(即沒有UI窗口和樣式)。
即時消息猜測,作爲頁面有回發它不知道它的以前的狀態。對於noob這樣的問題抱歉,我通常會在MVC項目上,並且可以在睡夢中做到這一點。
任何人都可以提供任何意見,我可以做什麼。代碼:
這從網格加載窗口:
$("a[name^='editSection_']").on("click", function (e) {
e.preventDefault();
var id = $(this).data("id");
var divDiag = $("#addEdit");
$.ajax({
url: "/edit.aspx?id=" + id,
success: function (data) {
$(divDiag).html(data);
$(divDiag).dialog({
show: { effect: 'drop', direction: "up" },
title: "Editing Feature Box",
height: 800,
width: 740,
modal: true,
resizable: false,
option: "show",
close: function (ev, ui) {
window.location.reload(true);
}
});
},
error: function (data) {
$(divDiag).html(data);
$(divDiag).dialog({
show: { effect: 'drop', direction: "up" },
title: "Editing Feature Box",
height: 800,
width: 740,
modal: true,
resizable: false,
option: "show",
close: function (ev, ui) {
window.location.reload(true);
}
});
}
});
這是圖片上傳的HTML ..
<asp:FileUpload ID="editImage" runat="server" />
<asp:Button ID="btnUploadImage" Text="Upload" runat="server" OnClick="btnUploadImage_Click" />
<asp:Label ID="lblUpload" runat="server"></asp:Label>
典論btnUploadImage運行:
protected void btnUploadImage_Click(object sender, EventArgs e)
{
if (editImage.HasFile)
{
try
{
.....code to upload sits here
上傳執行完成後,我想直接放回到UI窗口,其狀態與之前一樣。
任何幫助,不勝感激
我會喜歡使用Ajax以下的jQuery的組件。我可以使用MVC中的內容嗎?即捕捉按鈕點擊,e.preventdefault然後調用控制器動作來執行服務器位? – bruceiow
@bruceiow preventdefault通常可以正常工作,但上傳文件需要回傳才能上傳文件。還有很多其他的選項,我更新了我的建議的答案,請參閱[其他線程](http://stackoverflow.com/questions/35743/fileupload-control-inside-an-updatepanel-without-refreshing-the-whole更多 – nmat