Wednesday, October 7, 2009

Passing values between Flash and ASP.Net

Recently I had to integrate Flash and ASP.Net for Harley's test ride website because the website has been built in Flash and the data needs to be passed to which subsequently stores it in the MS-SQL database.

I had done it in the past and I was following the same approach but somehow the values which were returned from to flash were the complete code of the webpage whereas I was only passing "passed" or "invalid" to take some action in Flash depending upon the output from Asp.Net

After doing hours of search on the internet and R&D I finally found the problem and so to save time to my fellow developers I am posting the complete code below -

Flash Source Code:
var dataSender:LoadVars = new LoadVars();
var dataReceiver:LoadVars = new LoadVars();"";
dataReceiver.onLoad = function() {
if (dataReceiver.response == "invalid") {
} else if (dataReceiver.response == "passed") {
dataSender.sendAndLoad("bookatestride.aspx", dataReceiver, "GET");

C# Source Code:
public partial class bookatestride : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (....)

dataSender is calling the bookatestride.aspx page and passing one value in the variable called "email". In return aspx page is passing variable-value pair and that gets stored into the dataReceiver object.

I wasn't including "&" in the response.write and that was the reason I had wasted few hours trying to figure this out. So guys don't forget to include "&" in your Response.write

No comments: