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 asp.net 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 asp.net 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();
dataSender.email="atul.narang@designworxz.com";
dataReceiver.onLoad = function() {
if (dataReceiver.response == "invalid") {
gotoAndStop(1);
} else if (dataReceiver.response == "passed") {
gotoAndStop(4);
}
}
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 (....)
{
Response.Write("&response=passed&");
}
else
{
Response.Write("&response=invalid&");
}
}
}
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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment