By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,122 Members | 1,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,122 IT Pros & Developers. It's quick & easy.

Interactive/Non-interactive ASPX ?

P: n/a
WJ
I have three ASPX pages:

1. "WebForm1.aspx" is interactive, responsible for calling a web site
(https://www.payMe.com) with $$$. It is working fine.
2. "WebForm2.aspx" is non-interactive, a listener in my site to capture a
"STATUS_CD" returned by www.payMe.com. It is working fine.
3. "WebForm3.aspx" is interactive page, responsibe to display the STATUS
CODE "POSTED" by "WebForm2.aspx".

4. My goal is to use "WebForm2.aspx" to call "WebForm3.aspx" automatically
when it was POSTED by www.payMe.com without user involvement. But it did not
work and there was no error detected/displayed. To get around, in
"WebForm2.aspx", I had to write the status code to a local text file, then
in "WebForm1.aspx" (still present on the user's Browser while all these
behind-the-scence things are taking place), used a buttonClick event handler
to call "WebForm3.aspx" with the same code as shown below in
"WebForm2.aspx".

5. My code (c#) for "WebForm2.aspx" (listener page) is shown below:

************************************************** ****************
using several .netClasses;

namespace TestMe
{
public class WebForm2: System.Web.UI.Page //This page is a listener,
therefore, it is not interactive
{
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Request.Form.Keys.Count==0)
{
//Show Error: Failed on POST status returned from
www.payME.com;
return;
}

string sKey=""; //Name="STATUS_CODE"
string sVal=""; //Value="OK" or "NOT OK"
string sQ=@""""; //constant used for string concat.

//Step# 1 - Extract one Status code sent by
https://www.payME.com.
//This step always works

sKey=Request.Form.Keys[0].ToString();
sVal=Request[sKey].ToString();

//Step# 2 - Using "POST" method to send status code to
Action="WebForm3.aspx".
//This did not work, nor error was detected/shown.
//To make it work, comment these lines below and write the
status code to the disk,
//then have "WebForm1.aspx" reads the data from the disk and
call "WebForm3.aspx" to display it.
//Please note: These lines below will always work in
"WebForm1.aspx".

Response.Clear();
Response.Write("<HTML><HEAD></HEAD>");
Response.Write("<BODY onLoad="Document.Form1.submit()"+sQ+">");
Response.Write("<FORM NAME="+sQ+"Form1"+sQ+"
METHOD="+sQ+"Post"+sQ+" ACTION="+sQ+"Webform3.aspx"+sQ+" >");

//Place KeyName,Value pair here.

Response.Write("<INPUT NAME="+q+sKey+q+" TYPE="+sQ+"HIDDEN"+sQ+"
VALUE="+q+sVal+q+">");

//Finish
Response.Write("</FORM>");
Response.Write("</BODY></HTML>");
Response.End();
}
}
}
}
************************************************** ****************

Questions:

1. How do I force "WebForm2.aspx" to call "WebForm3.aspx" without having to
write the data to disk and read it back from the disk ?
2. Why the code in "WebForm2.aspx" above works fine in "WebForm1.aspx"
buttonClick Event ? Is it because it is interactive while "WebForm2.aspx" is
not ?

Thanks for your help

John Webbs
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
using several .netClasses;

namespace TestMe
{
public class WebForm2: System.Web.UI.Page //This page is a listener,
therefore, it is not interactive
{
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Request.Form.Keys.Count==0)
{
//Show Error: Failed on POST status returned from
www.payME.com;
return;
}

Session[sKey]=Request.Form.Keys[0].ToString();
Session[sVal]=Request[sKey].ToString();

Response.Redirect("page3.aspx");
}
}
}
}
Then remove keys on page 3. You can also use ViewState, although it is
easier to use with Framework 2.0. In addition, you can set up a queryline.

If you really want to post to another page, set up a JavaScript routine in
the page and call it from body load. That gives you the ability to test the
page properly. No matter what you do, you need to debug the page better.

BTW, your code follows an ASP methodology more than an ASP.NET methodology.
There is really no reason to transfer the person to another page. You can
encapsulate the logic in a class or move it to page 2 and get the same
benefit for the user.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"WJ" wrote:
I have three ASPX pages:

1. "WebForm1.aspx" is interactive, responsible for calling a web site
(https://www.payMe.com) with $$$. It is working fine.
2. "WebForm2.aspx" is non-interactive, a listener in my site to capture a
"STATUS_CD" returned by www.payMe.com. It is working fine.
3. "WebForm3.aspx" is interactive page, responsibe to display the STATUS
CODE "POSTED" by "WebForm2.aspx".

4. My goal is to use "WebForm2.aspx" to call "WebForm3.aspx" automatically
when it was POSTED by www.payMe.com without user involvement. But it did not
work and there was no error detected/displayed. To get around, in
"WebForm2.aspx", I had to write the status code to a local text file, then
in "WebForm1.aspx" (still present on the user's Browser while all these
behind-the-scence things are taking place), used a buttonClick event handler
to call "WebForm3.aspx" with the same code as shown below in
"WebForm2.aspx".

5. My code (c#) for "WebForm2.aspx" (listener page) is shown below:

************************************************** ****************
using several .netClasses;

namespace TestMe
{
public class WebForm2: System.Web.UI.Page //This page is a listener,
therefore, it is not interactive
{
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
if(Request.Form.Keys.Count==0)
{
//Show Error: Failed on POST status returned from
www.payME.com;
return;
}

string sKey=""; //Name="STATUS_CODE"
string sVal=""; //Value="OK" or "NOT OK"
string sQ=@""""; //constant used for string concat.

//Step# 1 - Extract one Status code sent by
https://www.payME.com.
//This step always works

sKey=Request.Form.Keys[0].ToString();
sVal=Request[sKey].ToString();

//Step# 2 - Using "POST" method to send status code to
Action="WebForm3.aspx".
//This did not work, nor error was detected/shown.
//To make it work, comment these lines below and write the
status code to the disk,
//then have "WebForm1.aspx" reads the data from the disk and
call "WebForm3.aspx" to display it.
//Please note: These lines below will always work in
"WebForm1.aspx".

Response.Clear();
Response.Write("<HTML><HEAD></HEAD>");
Response.Write("<BODY onLoad="Document.Form1.submit()"+sQ+">");
Response.Write("<FORM NAME="+sQ+"Form1"+sQ+"
METHOD="+sQ+"Post"+sQ+" ACTION="+sQ+"Webform3.aspx"+sQ+" >");

//Place KeyName,Value pair here.

Response.Write("<INPUT NAME="+q+sKey+q+" TYPE="+sQ+"HIDDEN"+sQ+"
VALUE="+q+sVal+q+">");

//Finish
Response.Write("</FORM>");
Response.Write("</BODY></HTML>");
Response.End();
}
}
}
}
************************************************** ****************

Questions:

1. How do I force "WebForm2.aspx" to call "WebForm3.aspx" without having to
write the data to disk and read it back from the disk ?
2. Why the code in "WebForm2.aspx" above works fine in "WebForm1.aspx"
buttonClick Event ? Is it because it is interactive while "WebForm2.aspx" is
not ?

Thanks for your help

John Webbs

Nov 19 '05 #2

P: n/a
WJ
Thank you Cowboy for your response,
Session[sKey]=Request.Form.Keys[0].ToString();
Session[sVal]=Request[sKey].ToString();
I found this technique to involve more works than it looks. Reason: I have
to attach a unique session ID or a User Logon ID to each Name,Value pair
because the site supports concurrent sessions (54+ users at the same time).
It sometime colides (data from users mixed up, not happening all the time, I
donot know why)
Response.Redirect("page3.aspx");
This instruction does not fire from a listener page. That is why I came here
for help. It only works from an interactive page. The samw holds true to
"Response.Write()";
Then remove keys on page 3. You can also use ViewState
I do not know this technique well enough to carve it into my current
application. Can you show a sample code.
although it is easier to use with Framework 2.0.
I am still on VS.Net 2003. 2.0 is another two years down the road.
In addition, you can set up a queryline.
Do you mean "Request.QueryString" ? If so, I am not allowed to use "GET'.
All activities between pages and sites must use "POST" method.
If you really want to post to another page, set up a JavaScript routine in
the page and call it from body load. That gives you the ability to test
the
page properly. No matter what you do, you need to debug the page better.
I love JS but certain functions I cannot use JS, mostly security and or data
sensitivity issues. The primary goal here is to have the listener page gets
the data from other site, then calls an .aspx page to display the data it
captures. But it does not work.
BTW, your code follows an ASP methodology more than an ASP.NET
methodology. Well, unfortunately it is working reliably, better than session (more work).
For "POST" method, this sure is a clumsy (Response.Write()) style but it
works with less effort :)
There is really no reason to transfer the person to another page. You can
encapsulate the logic in a class or move it to page 2 and get the same
benefit for the user.


I donot think you get my question right or I failed to explain it clear!
Here is the work flow:

1. My web page call your web page a thousand miles away.
2. Your web page responses to my listener page with a signal (OK or NOT OK)
3. My listener page then alerts my user about the signal received from your
page. This part does not fire up my alert page. As staed earlier, I had to
write the signal to the disk, then have another page to read it and alert
the user.

John
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.