PDA

View Full Version : [CLOSED] How to prevent sending viewstate / postdata to server on AjaxEvent?



jchau
Nov 12, 2008, 4:52 PM
Is there a way to prevent sending ViewState / PostData to the server during an AjaxEvent? I tried setting AjaxEvent.Type to 'Load' but it seems to be still sending them via url query string. Is it possible to set that property globally? Also, I have a grid with a server side OnRefreshData method. How do I configure AjaxEvent.Type for it? I tried Store.AjaxPostbackConfig.Type="Load" but it threw a javascript error. Thanks!



Line: 10
Error: The system cannot locate the resource specified.

Vladimir
Nov 13, 2008, 7:12 AM
Hi jchau,

I setted Type="Load" for the Store and I don't see ViewState in request. Params of my request


_dc 1226570883064
submitAjaxEventConfig {"config":{"__EVENTTARGET":"ScriptManager1","__EVENTARGUMENT":"Store1|postback|refresh","extraParams":{"start":20,"limit":10}}}


Are you sure that ViewState exists in your request?

About error... I am pretty sure that problem related with invalid url. Did you set Url in AjaxPostbackConfig?

If problems still occur then please post simple example which shows the problems

Hope this help

geoffrey.mcgill
Nov 14, 2008, 5:41 AM
Hi jchau,

Any update re: this ViewState/Load issue? Do you require any further assistence isolating the problem?

jchau
Nov 14, 2008, 1:57 PM
I verified that Type="Load" is indeed working for AjaxEvents. I must have been doing something wrong before. I still have a question about store.reload(). Here's a sample grid where on button click, it reloads the grid. How do I get that reload to not pass viewstate and postdata? Also, is there a way to set Type="Load" globally like ViewStateMode?



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Grid.aspx.vb" Inherits="CooliteSandbox.Grid" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<script runat="server">
Private Sub store_RefreshData(ByVal sender As Object, ByVal e As Coolite.Ext.Web.StoreRefreshDataEventArgs) Handles store.RefreshData
Me.store.DataSource = EmployeeFactory.GetEmployees
Me.store.DataBind()
End Sub
</script>
<ext:ScriptManager ID="ScriptManager1" Theme="Gray" runat="server">
</ext:ScriptManager>
<ext:Store ID="store" runat="server">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="LastName">
</ext:RecordField>
<ext:RecordField Name="FirstName">
</ext:RecordField>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:ViewPort ID="ViewPort1" runat="server">
<Body>
<ext:FitLayout ID="FitLayout1" runat="server">
<ext:GridPanel runat="server" ID="grid" StoreID="store">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn Fixed="true">
</ext:RowNumbererColumn>
<ext:Column DataIndex="LastName" Header="Last Name">
</ext:Column>
<ext:Column DataIndex="FirstName" Header="First Name">
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel runat="server">
</ext:CheckboxSelectionModel>
</SelectionModel>
<LoadMask ShowMask="true" />
<View>
<ext:GridView ForceFit="true">
</ext:GridView>
</View>
<Buttons>
<ext:Button runat="server" ID="btnLoad" Text="Reload">
<Listeners>
<Click Handler="#{store}.reload()" />
</Listeners>
</ext:Button>
</Buttons>
</ext:GridPanel>
</ext:FitLayout>
</Body>
</ext:ViewPort>
</form>
</body>
</html>

Vladimir
Nov 14, 2008, 3:13 PM
Hi jchau,

You can set Type=Load for store requests


<AjaxEventConfig Type="Load">
</AjaxEventConfig>


For now it is no way to set Type="Load" for all requests by default.
I think upcoming AjaxMethods can be real alternative because it used Type="Load"

jchau
Nov 14, 2008, 4:03 PM
Thanks! That worked.