0
我正在嘗試一個簡單的ajax表單,它將更新按鈕單擊上的標籤。有異步更新標籤的問題
我得到下面的錯誤:
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
低於上線功能: 「拋出的錯誤;」
function Sys$WebForms$PageRequestManager$_endPostBack(error, executor, data) {
if (this._request === executor.get_webRequest()) {
this._processingRequest = false;
this._additionalInput = null;
this._request = null;
}
var handler = this._get_eventHandlerList().getHandler("endRequest");
var errorHandled = false;
if (handler) {
var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
handler(this, eventArgs);
errorHandled = eventArgs.get_errorHandled();
}
if (error && !errorHandled) {
***throw error;***
}
}
這裏是我的表單代碼:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Hello";
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Test Form
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<div style="text-align: left; height: 395px;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" style="margin-left: 66px" Text="Button" Width="176px" />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</asp:Content>
我缺少的東西?
這不是MVC,只是普通的舊.net webforms :) – Tommy
已經有一段時間了,因爲我使用了updatePanels,但是在這種情況下,您的button1應該在更新面板之外?我可能會遠離基地,雖然... – Tommy
@Tommy保持更新面板外的button1確實擺脫了錯誤,但Lable1文本仍未更新爲「你好」 – user793468