0
我正在處理ASP.NET
Web應用程序。我在哪裏添加了ascx
控制器,裏面有一個asp:updatepanel
。現在的問題是,當試着讓它提供了以下錯誤的更新:MicrosoftAjax.js - PostBack POST 500(內部服務器錯誤)
MicrosoftAjax.js:5 POST http://localhost:49735/ 500 (Internal Server Error)
executeRequest @ MicrosoftAjax.js:5
executeRequest @ MicrosoftAjax.js:5
invoke @ MicrosoftAjax.js:5
_onFormSubmit @ MicrosoftAjaxWebForms.js:5
(anonymous function) @ MicrosoftAjax.js:5
b @ MicrosoftAjax.js:5
我ascx
文件看起來像這樣:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SearchResults.ascx.cs" Inherits="CarParts24.Controls.Search.Results.SearchResults" %>
<asp:UpdatePanel ID="UpdPnlSearchResults" runat="server">
<ContentTemplate>
<span id="search-result-json" class="hidden">
<asp:HiddenField ID="hiddenSearchResults" runat="server" />
</span>
<%--<asp:Panel ID="PanelResult" runat="server">--%>
<%-- Some ordinary HTML code --%>
<%--</asp:Panel>--%>
</ContentTemplate>
</asp:UpdatePanel>
和代碼隱藏:
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CarParts24.Controls.Search.Results
{
public partial class SearchResults : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
PanelResult.Visible = false;
}
public void ShowResults(DataTable datatable)
{
hiddenSearchResults.Value = JsonConvert.SerializeObject(datatable);
PanelResult.Visible = true;
}
}
}