Asp.net AJAX工作 - 但不工作

时间:2021-05-08 03:18:23

This is a weird one.

这很奇怪。

Long story short: wrote a usercontrol using AJAX. Used return of smart part v1.3 to plug it into a sharepoint 2007 (development) site.

长话短说:用AJAX写了一个usercontrol。使用智能部件v1.3的返回将其插入到sharepoint 2007(开发)站点。

Works perfectly!

完美的工作!

Moved it all to a production server - modified the web.config file to be exactly like the development site. It's not working.

将其全部移至生产服务器 - 将web.config文件修改为与开发站点完全相同。它不起作用。

It's weird because, I'm pretty sure the ajax is actually working, since the updateprogress is working, and I get an error in my ajax_endrequest js handler - after my second ajax request (as in - I press a button once, nothing, I press it again) I get:

这很奇怪因为,我很确定ajax实际上正在工作,因为updateprogress正在工作,我在我的ajax_endrequest js处理程序中得到一个错误 - 在我的第二个ajax请求之后(如在 - 我按了一次按钮,没有,我再按一次)我得到:

"Invalid postback or callback argument. Event validation is enabled using in configuration..."

“无效的回发或回调参数。使用配置启用事件验证...”

I have a linkbutton with javascript__doPostback, which seems to work - at least it's running the code - but it's not updating anything in the updatepanel.

我有一个带有javascript__doPostback的链接按钮,它似乎有效 - 至少它正在运行代码 - 但它没有在updatepanel中更新任何内容。

Another example of it not working: I have a tab-panel, and a listbox set to autocomplete. In the selectedindexchanged I change the active tab panel - but this isn't working. When I do it twice I get the same aforementioned error back in my javascript end request handler.

它的另一个例子不起作用:我有一个标签面板,一个列表框设置为自动完成。在selectedindexchanged中,我更改了活动选项卡面板 - 但这不起作用。当我这样做两次时,我在我的javascript结束请求处理程序中得到了相同的上述错误。

Can ANYONE point me in ANY direction!? :)

任何人都能指出我的任何方向!? :)

2 个解决方案

#1


1  

Okay...

好的...

I have to vent. This problem took me way too long to fix.

我要发泄。这个问题花了我太长时间才解决。

The problem was in the masterpage in sharepoint. Since I wasn't using the default masterpage, apparently this line:

问题出在sharepoint的母版页中。由于我没有使用默认主页,显然这行:

<WebPartPages:SPWebPartManager runat="server"/>

Was outside the tag - when it's moved down inside it (which is is in the default-masterpage, I was using on my development machine), everything works great -.-

在标签之外 - 当它在它内部移动时(这是在我的开发机器上使用的默认主页中),一切都很好 - .-

I hate sharepoint sometimes...

我有时讨厌分享...

#2


0  

I think because you are using AJAX you are running into issues with event validaiton. Since the JavaScript is firing events, ASP.NET cannot verify the source of the triggered event handlers thus throwing errors left and right.

我认为因为您使用的是AJAX,所以您遇到了事件验证问题。由于JavaScript是触发事件,因此ASP.NET无法验证触发事件处理程序的来源,从而左右抛出错误。

You can disable event validation globaly:

您可以禁用全局事件验证:

<system.web>
   <pages enableEventValidation="false"/>
</system.web>

or on a single page:

或在一个页面上:

<%@ Page EnableEventValidation="false" ... %>

The same applies for view state validation... on controls that JavaScript has interacted on... And here is the code to fix it:

这同样适用于JavaScript已经与之交互的控件上的视图状态验证...以下是修复它的代码:

web config:

网络配置:

<pages enableViewState="false" />

or on a single page:

或在一个页面上:

<%@ Page ... EnableViewState="false" %>

#1


1  

Okay...

好的...

I have to vent. This problem took me way too long to fix.

我要发泄。这个问题花了我太长时间才解决。

The problem was in the masterpage in sharepoint. Since I wasn't using the default masterpage, apparently this line:

问题出在sharepoint的母版页中。由于我没有使用默认主页,显然这行:

<WebPartPages:SPWebPartManager runat="server"/>

Was outside the tag - when it's moved down inside it (which is is in the default-masterpage, I was using on my development machine), everything works great -.-

在标签之外 - 当它在它内部移动时(这是在我的开发机器上使用的默认主页中),一切都很好 - .-

I hate sharepoint sometimes...

我有时讨厌分享...

#2


0  

I think because you are using AJAX you are running into issues with event validaiton. Since the JavaScript is firing events, ASP.NET cannot verify the source of the triggered event handlers thus throwing errors left and right.

我认为因为您使用的是AJAX,所以您遇到了事件验证问题。由于JavaScript是触发事件,因此ASP.NET无法验证触发事件处理程序的来源,从而左右抛出错误。

You can disable event validation globaly:

您可以禁用全局事件验证:

<system.web>
   <pages enableEventValidation="false"/>
</system.web>

or on a single page:

或在一个页面上:

<%@ Page EnableEventValidation="false" ... %>

The same applies for view state validation... on controls that JavaScript has interacted on... And here is the code to fix it:

这同样适用于JavaScript已经与之交互的控件上的视图状态验证...以下是修复它的代码:

web config:

网络配置:

<pages enableViewState="false" />

or on a single page:

或在一个页面上:

<%@ Page ... EnableViewState="false" %>