473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Script callback returning ViewState?

Okay, I'm pretty baffled by this one.

I've got a page in a popup which takes a postcode; looks up a list of
addresses for that postcode; then uses a callback to get the details
for a specific address, build a JS object and pass it back to the
window.opener.

This used to work, but without any obvious cause it has started
throwing an error. The error text comprises the XML returned from the
server AND (mysteriously) the viewstate. Here's the callback method:

<code>

public string GetCallbackResult()
{
return LoadSingleAddressAsXml(_callbackArg);
}

private string LoadSingleAddressAsXml(string addressId)
{
Connection accountDetails = GetAccountDetails();
PostcodeAnywhereProvider data = new
PostcodeAnywhereProvider(accountDetails);
FullAddress address = data.getAddress(addressId);

StringWriter Output = new StringWriter(new StringBuilder());
XmlSerializer s = new XmlSerializer( typeof( FullAddress ) );
s.Serialize(Output,address);

Trace.Warn(Output.ToString());

return outstring;
}

</code>

The trace shows a perfectly correct response without any additional
text.

The JS looks like this

<code>
addInitFunc(initCallback);

function initCallback()
{
pageUrl='/PostcodePopup.aspx';
_InitWebCallback();
}
function doCallback()
{
var list = getSingleElement("selAddress", "select");
var aId = list.options[list.selectedIndex].value;

WebForm_DoCallback('__Page',aId,receiveCallBack,nu ll,oncallbackerror,true);
}

function onCallbackError(e)
{
alert("Oops! An error occurred while contacting the server!\nPlease
try again in a moment\n"+e);
}

function receiveCallBack(xml)
{
var oDomDoc = Sarissa.getDomDocument();
oDomDoc.loadXML(xml);
var oAddress = parseAddress(oDomDoc);
sendAddress(oAddress);
}
</code>

The onCallbackError function is called and my alert runs something like

Oops! An error occurred on the server, please try again in a moment
/wEWHQLggdzjDgLJrO+CAQLAzrGoBwLt/YqPAwLO547CDgLt/ZbPAgLO55qCDgLt/dIPAs7n1sIPAu39vs8DAs7nooIPAu39+o8BAs7nvsQEAu39xk8 CzueKhAQCk6Wj9QcC7f2Cjg4Ck6WPtQcC7f3uzwECk6XL9QQC7 f3qgQcCk6XXtQQC7f32wQYCk6WT9AUCzufeQwKTpf+1BQLO56o DAs7n5sMBAs7n8oMBOUBN2Lkkie4wjPMIfrnhEv/BivE=
<Address Building="My Parent's Address" Street="My Parent's Road"
Locality1="Deepest Darkest Derbyshire" Locality2=" Locality3=""
town="None Worth Mention" postcode="ABC 123" county="Derbyshire"
country-id="335" address-id="0" />

Dec 1 '05 #1
2 2951
Hi,

Did you check whether XML you are getting is valid? Please post XML

"Flinky Wisty Pomm" <Pa********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Okay, I'm pretty baffled by this one.

I've got a page in a popup which takes a postcode; looks up a list of
addresses for that postcode; then uses a callback to get the details
for a specific address, build a JS object and pass it back to the
window.opener.

This used to work, but without any obvious cause it has started
throwing an error. The error text comprises the XML returned from the
server AND (mysteriously) the viewstate. Here's the callback method:

<code>

public string GetCallbackResult()
{
return LoadSingleAddressAsXml(_callbackArg);
}

private string LoadSingleAddressAsXml(string addressId)
{
Connection accountDetails = GetAccountDetails();
PostcodeAnywhereProvider data = new
PostcodeAnywhereProvider(accountDetails);
FullAddress address = data.getAddress(addressId);

StringWriter Output = new StringWriter(new StringBuilder());
XmlSerializer s = new XmlSerializer( typeof( FullAddress ) );
s.Serialize(Output,address);

Trace.Warn(Output.ToString());

return outstring;
}

</code>

The trace shows a perfectly correct response without any additional
text.

The JS looks like this

<code>
addInitFunc(initCallback);

function initCallback()
{
pageUrl='/PostcodePopup.aspx';
_InitWebCallback();
}
function doCallback()
{
var list = getSingleElement("selAddress", "select");
var aId = list.options[list.selectedIndex].value;

WebForm_DoCallback('__Page',aId,receiveCallBack,nu ll,oncallbackerror,true);
}

function onCallbackError(e)
{
alert("Oops! An error occurred while contacting the server!\nPlease
try again in a moment\n"+e);
}

function receiveCallBack(xml)
{
var oDomDoc = Sarissa.getDomDocument();
oDomDoc.loadXML(xml);
var oAddress = parseAddress(oDomDoc);
sendAddress(oAddress);
}
</code>

The onCallbackError function is called and my alert runs something like

Oops! An error occurred on the server, please try again in a moment
/wEWHQLggdzjDgLJrO+CAQLAzrGoBwLt/YqPAwLO547CDgLt/ZbPAgLO55qCDgLt/dIPAs7n1sIPAu39vs8DAs7nooIPAu39+o8BAs7nvsQEAu39xk8 CzueKhAQCk6Wj9QcC7f2Cjg4Ck6WPtQcC7f3uzwECk6XL9QQC7 f3qgQcCk6XXtQQC7f32wQYCk6WT9AUCzufeQwKTpf+1BQLO56o DAs7n5sMBAs7n8oMBOUBN2Lkkie4wjPMIfrnhEv/BivE=
<Address Building="My Parent's Address" Street="My Parent's Road"
Locality1="Deepest Darkest Derbyshire" Locality2=" Locality3=""
town="None Worth Mention" postcode="ABC 123" county="Derbyshire"
country-id="335" address-id="0" />

Dec 1 '05 #2
It's not a problem with the XML because no validation is occurring at
any point - the script callback just returns a string, which in this
case happens to be an XML fragment, but I might switch to JScript
objects at some point. The error occurs before the document is loaded
because control passes to onCallbackError instead of receiveCallback.

The XML is fine, and matches what I get in the alert() except that the
alert also contains the ViewState

Forgive the odd schema but I've not finished setting up the
serialization.

<code>

<?xml version="1.0" encoding="utf-16"?>
<Address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" Building="3 Dale Avenue"
Street="Dale Avenue" Locality1="Long Eaton" Locality2="" Locality3=""
town="Nottingham" postcode="NG10 1NP" county="Derbyshire"
country-id="335" address-id="0">
<CountyId>0</CountyId>
<Country>United Kingdom</Country>
<CountryCode>uk</CountryCode>
<AddressStartDate>0001-01-01T00:00:00</AddressStartDate>
<AddressEndDate>0001-01-01T00:00:00</AddressEndDate>
<IsPrimaryAddress>false</IsPrimaryAddress>
</Address>

</code>

Dec 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a...
8
by: kurtcobain1978 | last post by:
-------------------------------------------------------------------------------- I need to do the exactly same thing in VB.NET. Load a unmanaged C DLL dynamically and then call a function in...
0
by: smilly | last post by:
I was wondering if there was a way to save viewstate information for the Page from a CallBack in general. Examples would be good :-)
7
by: kelly | last post by:
Hi I have an app where I have 2 dropdown lists (state and city) and a Save button. When a user selects a value from the state dropdown list, I use script callback to populate the data for the...
2
by: FatherUCKing | last post by:
I'm trying to implement an add / remove listbox system ...one listbox has available values the second represents the saved values. Using the client-callback features, how would I write the code to...
0
by: Brian | last post by:
Hi, I've been trying to get a simple client / script callback to work. I was using IE6 to the ASP Development Server / IIS 5 and it just didn't work. I ended up using an example straight from an...
0
by: Udi | last post by:
Hi all, I'm having difficulties returning a buffer allocated on a callback called from a native dll to .NET assembly. (See pseudo code below in "Foo" func): The managed assembly (the called back...
2
by: Fabio Mastria | last post by:
Hi all! In a my simple project I use callback to fill a dropdownlist with xml data returned by a web service, based on a value which is input via another dropdownlist. NOTE: I can't use...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.