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

method post problem

P: n/a
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>
Nov 19 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Hi Britney,

"Cross page postback" is not a feature of ASP.NET 1.x, as you just
discovered. It is however a feature in ASP.NET 2.0 (currently in beta
release) where a button can have a value for a PostBackUrl property. You can
read about this feature on the ASP.NET 2.0 Quickstart tutorials
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

Currently, you would have to use Server.Transfer(URL, bool) in response for
a ButtonClick event to transfer your form to another page; the bool parameter
would determine if want to keep (true) or clear (false) the Form and
QueryString collections. This link has the full syntax of the transfer
method:
http://msdn.microsoft.com/library/de...nsfertopic.asp

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>

Nov 19 '05 #2

P: n/a
With Server Controls, such as the text boxes and the button below, ASP.NET
relies on post-back capability. If you view-source on the html page you will
see that the ACTION attribute has been changed.

Alternatively, in the code-behind for the button_click event you can
server.transfer or response.redirect to the other page.

"Britney" wrote:
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</form>

Nov 19 '05 #3

P: n/a


I tried the following in my code-behind cs file, but it doesn't work.

I don't see it redirect to testing2.aspx..

So this is strange, any idea?

private void Button1_Click(object sender, System.EventArgs e)

{
Server.Transfer("testing2.aspx", true);

}

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:18**********************************@microsof t.com...
Hi Britney,

"Cross page postback" is not a feature of ASP.NET 1.x, as you just
discovered. It is however a feature in ASP.NET 2.0 (currently in beta
release) where a button can have a value for a PostBackUrl property. You
can
read about this feature on the ASP.NET 2.0 Quickstart tutorials
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

Currently, you would have to use Server.Transfer(URL, bool) in response
for
a ButtonClick event to transfer your form to another page; the bool
parameter
would determine if want to keep (true) or clear (false) the Form and
QueryString collections. This link has the full syntax of the transfer
method:
http://msdn.microsoft.com/library/de...nsfertopic.asp

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default
page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</form>

Nov 19 '05 #4

P: n/a
oh.. I can see it's doing redirect now.
when I view source, I can see the contents of html code are from page2.aspx.

however, the URL stay the same, it's still default.aspx
I wonder why...????

"Brad Roberts" <Br*****************@hotmail.com> wrote in message
news:87**********************************@microsof t.com...
With Server Controls, such as the text boxes and the button below, ASP.NET
relies on post-back capability. If you view-source on the html page you
will
see that the ACTION attribute has been changed.

Alternatively, in the code-behind for the button_click event you can
server.transfer or response.redirect to the other page.

"Britney" wrote:
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default
page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</form>

Nov 19 '05 #5

P: n/a
Hi Britney,

Notice that server.transfer does not cause the browser Address line to
change to indicate the new URL (this is probably why you thought it did not
work), but if you put any action in the Page_Load of the new page you will
realize that the second page is running.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:


I tried the following in my code-behind cs file, but it doesn't work.

I don't see it redirect to testing2.aspx..

So this is strange, any idea?

private void Button1_Click(object sender, System.EventArgs e)

{
Server.Transfer("testing2.aspx", true);

}

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:18**********************************@microsof t.com...
Hi Britney,

"Cross page postback" is not a feature of ASP.NET 1.x, as you just
discovered. It is however a feature in ASP.NET 2.0 (currently in beta
release) where a button can have a value for a PostBackUrl property. You
can
read about this feature on the ASP.NET 2.0 Quickstart tutorials
http://beta.asp.net/QUICKSTART/aspne...s/default.aspx

Currently, you would have to use Server.Transfer(URL, bool) in response
for
a ButtonClick event to transfer your form to another page; the bool
parameter
would determine if want to keep (true) or clear (false) the Form and
QueryString collections. This link has the full syntax of the transfer
method:
http://msdn.microsoft.com/library/de...nsfertopic.asp

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
Hi guys,
in my default.aspx file, I have following code.
when I go to browser, I enter values in both textboxs, then I hit submit
Button,
however, it didn't go to page2.aspx. instead, it was still in default
page.
I thought Action will direct page to page2.aspx, no???
<form id="Form1" method="post" runat="server" action="page2.aspx">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button>
</form>


Nov 19 '05 #6

P: n/a
okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is because I
want testing2.aspx receive values of two textboxes from default.aspx page.
if I do server.redirect, then how can testing2.aspx remember those values I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
Hi Britney,

Notice that server.transfer does not cause the browser Address line to
change to indicate the new URL (this is probably why you thought it did
not
work), but if you put any action in the Page_Load of the new page you will
realize that the second page is running.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:


I tried the following in my code-behind cs file, but it doesn't work.

I don't see it redirect to testing2.aspx..

So this is strange, any idea?

private void Button1_Click(object sender, System.EventArgs e)

{
Server.Transfer("testing2.aspx", true);

}

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:18**********************************@microsof t.com...
> Hi Britney,
>
> "Cross page postback" is not a feature of ASP.NET 1.x, as you just
> discovered. It is however a feature in ASP.NET 2.0 (currently in beta
> release) where a button can have a value for a PostBackUrl property.
> You
> can
> read about this feature on the ASP.NET 2.0 Quickstart tutorials
> http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>
> Currently, you would have to use Server.Transfer(URL, bool) in response
> for
> a ButtonClick event to transfer your form to another page; the bool
> parameter
> would determine if want to keep (true) or clear (false) the Form and
> QueryString collections. This link has the full syntax of the transfer
> method:
> http://msdn.microsoft.com/library/de...nsfertopic.asp
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>> Hi guys,
>> in my default.aspx file, I have following code.
>> when I go to browser, I enter values in both textboxs, then I hit
>> submit
>> Button,
>> however, it didn't go to page2.aspx. instead, it was still in default
>> page.
>> I thought Action will direct page to page2.aspx, no???
>>
>>
>> <form id="Form1" method="post" runat="server" action="page2.aspx">
>> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> <asp:Button id="Button1" runat="server"
>> Text="Button"></asp:Button>
>> </form>
>>
>>
>>


Nov 19 '05 #7

P: n/a
Hi Britney,

If you were to use Server.Transfer ("secondPage.aspx", true); in the first
page then you can access the values of the textboxes in the second page using
the forms collections, e.g. Request.Form["txtBox1"] would get you the value
inside the textbox with the id “txtBox1” that the user entered on the first
page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is because I
want testing2.aspx receive values of two textboxes from default.aspx page.
if I do server.redirect, then how can testing2.aspx remember those values I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
Hi Britney,

Notice that server.transfer does not cause the browser Address line to
change to indicate the new URL (this is probably why you thought it did
not
work), but if you put any action in the Page_Load of the new page you will
realize that the second page is running.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:


I tried the following in my code-behind cs file, but it doesn't work.

I don't see it redirect to testing2.aspx..

So this is strange, any idea?

private void Button1_Click(object sender, System.EventArgs e)

{
Server.Transfer("testing2.aspx", true);

}

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:18**********************************@microsof t.com...
> Hi Britney,
>
> "Cross page postback" is not a feature of ASP.NET 1.x, as you just
> discovered. It is however a feature in ASP.NET 2.0 (currently in beta
> release) where a button can have a value for a PostBackUrl property.
> You
> can
> read about this feature on the ASP.NET 2.0 Quickstart tutorials
> http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>
> Currently, you would have to use Server.Transfer(URL, bool) in response
> for
> a ButtonClick event to transfer your form to another page; the bool
> parameter
> would determine if want to keep (true) or clear (false) the Form and
> QueryString collections. This link has the full syntax of the transfer
> method:
> http://msdn.microsoft.com/library/de...nsfertopic.asp
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>> Hi guys,
>> in my default.aspx file, I have following code.
>> when I go to browser, I enter values in both textboxs, then I hit
>> submit
>> Button,
>> however, it didn't go to page2.aspx. instead, it was still in default
>> page.
>> I thought Action will direct page to page2.aspx, no???
>>
>>
>> <form id="Form1" method="post" runat="server" action="page2.aspx">
>> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> <asp:Button id="Button1" runat="server"
>> Text="Button"></asp:Button>
>> </form>
>>
>>
>>


Nov 19 '05 #8

P: n/a
Thank you very much..
Now I think I'm getting better and better on this stuff.

One more question,
I do not want user to go to secondPage.aspx directly.
in order to get into second page, user must go through firstPage.aspx first
(by submitting form)

how do I do that?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:36**********************************@microsof t.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.aspx", true); in the first
page then you can access the values of the textboxes in the second page
using
the forms collections, e.g. Request.Form["txtBox1"] would get you the
value
inside the textbox with the id "txtBox1" that the user entered on the
first
page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is
because I
want testing2.aspx receive values of two textboxes from default.aspx
page.
if I do server.redirect, then how can testing2.aspx remember those values
I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
> Hi Britney,
>
> Notice that server.transfer does not cause the browser Address line to
> change to indicate the new URL (this is probably why you thought it did
> not
> work), but if you put any action in the Page_Load of the new page you
> will
> realize that the second page is running.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>>
>>
>> I tried the following in my code-behind cs file, but it doesn't work.
>>
>> I don't see it redirect to testing2.aspx..
>>
>> So this is strange, any idea?
>>
>>
>>
>> private void Button1_Click(object sender, System.EventArgs e)
>>
>> {
>>
>>
>> Server.Transfer("testing2.aspx", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
>> news:18**********************************@microsof t.com...
>> > Hi Britney,
>> >
>> > "Cross page postback" is not a feature of ASP.NET 1.x, as you just
>> > discovered. It is however a feature in ASP.NET 2.0 (currently in
>> > beta
>> > release) where a button can have a value for a PostBackUrl property.
>> > You
>> > can
>> > read about this feature on the ASP.NET 2.0 Quickstart tutorials
>> > http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>> >
>> > Currently, you would have to use Server.Transfer(URL, bool) in
>> > response
>> > for
>> > a ButtonClick event to transfer your form to another page; the bool
>> > parameter
>> > would determine if want to keep (true) or clear (false) the Form and
>> > QueryString collections. This link has the full syntax of the
>> > transfer
>> > method:
>> > http://msdn.microsoft.com/library/de...nsfertopic.asp
>> >
>> > --
>> > HTH,
>> > Phillip Williams
>> > http://www.societopia.net
>> > http://www.webswapp.com
>> >
>> >
>> > "Britney" wrote:
>> >
>> >> Hi guys,
>> >> in my default.aspx file, I have following code.
>> >> when I go to browser, I enter values in both textboxs, then I hit
>> >> submit
>> >> Button,
>> >> however, it didn't go to page2.aspx. instead, it was still in
>> >> default
>> >> page.
>> >> I thought Action will direct page to page2.aspx, no???
>> >>
>> >>
>> >> <form id="Form1" method="post" runat="server" action="page2.aspx">
>> >> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> >> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> >> <asp:Button id="Button1" runat="server"
>> >> Text="Button"></asp:Button>
>> >> </form>
>> >>
>> >>
>> >>
>>
>>
>>


Nov 19 '05 #9

P: n/a
On the second page, I put these code in the page_load section, however,
even if I submit first page, IsPostBack is still FALSE. why?
if (IsPostBack==false)

{

Response.Write("Must going through first page");
}

else

{

......................

}

"Britney" <br**************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Thank you very much..
Now I think I'm getting better and better on this stuff.

One more question,
I do not want user to go to secondPage.aspx directly.
in order to get into second page, user must go through firstPage.aspx
first (by submitting form)

how do I do that?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:36**********************************@microsof t.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.aspx", true); in the
first
page then you can access the values of the textboxes in the second page
using
the forms collections, e.g. Request.Form["txtBox1"] would get you the
value
inside the textbox with the id "txtBox1" that the user entered on the
first
page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is
because I
want testing2.aspx receive values of two textboxes from default.aspx
page.
if I do server.redirect, then how can testing2.aspx remember those
values I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
> Hi Britney,
>
> Notice that server.transfer does not cause the browser Address line to
> change to indicate the new URL (this is probably why you thought it
> did
> not
> work), but if you put any action in the Page_Load of the new page you
> will
> realize that the second page is running.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>>
>>
>> I tried the following in my code-behind cs file, but it doesn't work.
>>
>> I don't see it redirect to testing2.aspx..
>>
>> So this is strange, any idea?
>>
>>
>>
>> private void Button1_Click(object sender, System.EventArgs e)
>>
>> {
>>
>>
>> Server.Transfer("testing2.aspx", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
>> news:18**********************************@microsof t.com...
>> > Hi Britney,
>> >
>> > "Cross page postback" is not a feature of ASP.NET 1.x, as you just
>> > discovered. It is however a feature in ASP.NET 2.0 (currently in
>> > beta
>> > release) where a button can have a value for a PostBackUrl
>> > property.
>> > You
>> > can
>> > read about this feature on the ASP.NET 2.0 Quickstart tutorials
>> > http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>> >
>> > Currently, you would have to use Server.Transfer(URL, bool) in
>> > response
>> > for
>> > a ButtonClick event to transfer your form to another page; the bool
>> > parameter
>> > would determine if want to keep (true) or clear (false) the Form
>> > and
>> > QueryString collections. This link has the full syntax of the
>> > transfer
>> > method:
>> > http://msdn.microsoft.com/library/de...nsfertopic.asp
>> >
>> > --
>> > HTH,
>> > Phillip Williams
>> > http://www.societopia.net
>> > http://www.webswapp.com
>> >
>> >
>> > "Britney" wrote:
>> >
>> >> Hi guys,
>> >> in my default.aspx file, I have following code.
>> >> when I go to browser, I enter values in both textboxs, then I hit
>> >> submit
>> >> Button,
>> >> however, it didn't go to page2.aspx. instead, it was still in
>> >> default
>> >> page.
>> >> I thought Action will direct page to page2.aspx, no???
>> >>
>> >>
>> >> <form id="Form1" method="post" runat="server"
>> >> action="page2.aspx">
>> >> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> >> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> >> <asp:Button id="Button1" runat="server"
>> >> Text="Button"></asp:Button>
>> >> </form>
>> >>
>> >>
>> >>
>>
>>
>>


Nov 19 '05 #10

P: n/a
I think IsPostBack doesn't work with Server.Transfer.

In version 1.1, the transfer is not considered part of the postback and Page.IsPostBack is set to false even if Server.Transfer transfers back to itself.
http://support.microsoft.com/?kbid=821758

what should I do to get around this problem?
"Britney" <br**************@yahoo.com> wrote in message news:Ou****************@TK2MSFTNGP09.phx.gbl...
On the second page, I put these code in the page_load section, however,
even if I submit first page, IsPostBack is still FALSE. why?


if (IsPostBack==false)

{

Response.Write("Must going through first page");


}

else

{

.....................

}

"Britney" <br**************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Thank you very much..
Now I think I'm getting better and better on this stuff.

One more question,
I do not want user to go to secondPage.aspx directly.
in order to get into second page, user must go through firstPage.aspx
first (by submitting form)

how do I do that?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:36**********************************@microsof t.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.aspx", true); in the
first
page then you can access the values of the textboxes in the second page
using
the forms collections, e.g. Request.Form["txtBox1"] would get you the
value
inside the textbox with the id "txtBox1" that the user entered on the
first
page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:

okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is
because I
want testing2.aspx receive values of two textboxes from default.aspx
page.
if I do server.redirect, then how can testing2.aspx remember those
values I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
> Hi Britney,
>
> Notice that server.transfer does not cause the browser Address line to
> change to indicate the new URL (this is probably why you thought it
> did
> not
> work), but if you put any action in the Page_Load of the new page you
> will
> realize that the second page is running.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>>
>>
>> I tried the following in my code-behind cs file, but it doesn't work.
>>
>> I don't see it redirect to testing2.aspx..
>>
>> So this is strange, any idea?
>>
>>
>>
>> private void Button1_Click(object sender, System.EventArgs e)
>>
>> {
>>
>>
>> Server.Transfer("testing2.aspx", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
>> news:18**********************************@microsof t.com...
>> > Hi Britney,
>> >
>> > "Cross page postback" is not a feature of ASP.NET 1.x, as you just
>> > discovered. It is however a feature in ASP.NET 2.0 (currently in
>> > beta
>> > release) where a button can have a value for a PostBackUrl
>> > property.
>> > You
>> > can
>> > read about this feature on the ASP.NET 2.0 Quickstart tutorials
>> > http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>> >
>> > Currently, you would have to use Server.Transfer(URL, bool) in
>> > response
>> > for
>> > a ButtonClick event to transfer your form to another page; the bool
>> > parameter
>> > would determine if want to keep (true) or clear (false) the Form
>> > and
>> > QueryString collections. This link has the full syntax of the
>> > transfer
>> > method:
>> > http://msdn.microsoft.com/library/de...nsfertopic.asp
>> >
>> > --
>> > HTH,
>> > Phillip Williams
>> > http://www.societopia.net
>> > http://www.webswapp.com
>> >
>> >
>> > "Britney" wrote:
>> >
>> >> Hi guys,
>> >> in my default.aspx file, I have following code.
>> >> when I go to browser, I enter values in both textboxs, then I hit
>> >> submit
>> >> Button,
>> >> however, it didn't go to page2.aspx. instead, it was still in
>> >> default
>> >> page.
>> >> I thought Action will direct page to page2.aspx, no???
>> >>
>> >>
>> >> <form id="Form1" method="post" runat="server"
>> >> action="page2.aspx">
>> >> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> >> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> >> <asp:Button id="Button1" runat="server"
>> >> Text="Button"></asp:Button>
>> >> </form>
>> >>
>> >>
>> >>
>>
>>
>>




Nov 19 '05 #11

P: n/a
Hi Britney,

Regarding your two questions:

1- you can prevent going to the second page without the first by checking
the Request.UrlReferrer. However, you should probably design your
application to use the natural asp.net postback programming model (i.e.
posting to the page itself, instead to a second page). You will find it
much easier this way to reference the objects on the page. For example
instead of transferring the form of the first page to another page you can
simply have a function within your first page to do every thing that the
second page would do. You would call this function from the Button1_Click
method. This way you refer to the objects by their id directly instead of
referring to them by Request.Form[id]. It will also prove advantageous in
processing events fired by the different controls on the form.
2- IsPostBack is a property of the page that is handling the request. In
your example the second page only received data transferred from the first
page but it did not post back yet. This is another reason why you should
have used the first page to handle all functions that require you determining
whether a page is postback or not.
In summary you would find it much easier to have your ASP.NET web forms
handle their own postback, instead of trying to emulate the ASP model of
posting the form to another web page. It is good to know however that you
can transfer to another page if you needed to.

You might also look up the many samples written on asp.net on the msdn and
will feel comfortable using the Postback to the same page strategy. It might
help you too if you find a book about Object Oriented Programming to be able
to utilize the many powerful features of programming the asp.net environment.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
On the second page, I put these code in the page_load section, however,
even if I submit first page, IsPostBack is still FALSE. why?
if (IsPostBack==false)

{

Response.Write("Must going through first page");
}

else

{

......................

}

"Britney" <br**************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Thank you very much..
Now I think I'm getting better and better on this stuff.

One more question,
I do not want user to go to secondPage.aspx directly.
in order to get into second page, user must go through firstPage.aspx
first (by submitting form)

how do I do that?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:36**********************************@microsof t.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.aspx", true); in the
first
page then you can access the values of the textboxes in the second page
using
the forms collections, e.g. Request.Form["txtBox1"] would get you the
value
inside the textbox with the id "txtBox1" that the user entered on the
first
page.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:

okay.. .you're absolutely right..
Now... the reason I want to do "action" in the form originally is
because I
want testing2.aspx receive values of two textboxes from default.aspx
page.
if I do server.redirect, then how can testing2.aspx remember those
values I
entered from prevous page?
"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
> Hi Britney,
>
> Notice that server.transfer does not cause the browser Address line to
> change to indicate the new URL (this is probably why you thought it
> did
> not
> work), but if you put any action in the Page_Load of the new page you
> will
> realize that the second page is running.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Britney" wrote:
>
>>
>>
>> I tried the following in my code-behind cs file, but it doesn't work.
>>
>> I don't see it redirect to testing2.aspx..
>>
>> So this is strange, any idea?
>>
>>
>>
>> private void Button1_Click(object sender, System.EventArgs e)
>>
>> {
>>
>>
>> Server.Transfer("testing2.aspx", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
>> news:18**********************************@microsof t.com...
>> > Hi Britney,
>> >
>> > "Cross page postback" is not a feature of ASP.NET 1.x, as you just
>> > discovered. It is however a feature in ASP.NET 2.0 (currently in
>> > beta
>> > release) where a button can have a value for a PostBackUrl
>> > property.
>> > You
>> > can
>> > read about this feature on the ASP.NET 2.0 Quickstart tutorials
>> > http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>> >
>> > Currently, you would have to use Server.Transfer(URL, bool) in
>> > response
>> > for
>> > a ButtonClick event to transfer your form to another page; the bool
>> > parameter
>> > would determine if want to keep (true) or clear (false) the Form
>> > and
>> > QueryString collections. This link has the full syntax of the
>> > transfer
>> > method:
>> > http://msdn.microsoft.com/library/de...nsfertopic.asp
>> >
>> > --
>> > HTH,
>> > Phillip Williams
>> > http://www.societopia.net
>> > http://www.webswapp.com
>> >
>> >
>> > "Britney" wrote:
>> >
>> >> Hi guys,
>> >> in my default.aspx file, I have following code.
>> >> when I go to browser, I enter values in both textboxs, then I hit
>> >> submit
>> >> Button,
>> >> however, it didn't go to page2.aspx. instead, it was still in
>> >> default
>> >> page.
>> >> I thought Action will direct page to page2.aspx, no???
>> >>
>> >>
>> >> <form id="Form1" method="post" runat="server"
>> >> action="page2.aspx">
>> >> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>> >> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>> >> <asp:Button id="Button1" runat="server"
>> >> Text="Button"></asp:Button>
>> >> </form>
>> >>
>> >>
>> >>
>>
>>
>>



Nov 19 '05 #12

P: n/a
thank you.. you're very nice.

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:AD**********************************@microsof t.com...
Hi Britney,

Regarding your two questions:

1- you can prevent going to the second page without the first by checking
the Request.UrlReferrer. However, you should probably design your
application to use the natural asp.net postback programming model (i.e.
posting to the page itself, instead to a second page). You will find it
much easier this way to reference the objects on the page. For example
instead of transferring the form of the first page to another page you can
simply have a function within your first page to do every thing that the
second page would do. You would call this function from the Button1_Click
method. This way you refer to the objects by their id directly instead of
referring to them by Request.Form[id]. It will also prove advantageous in
processing events fired by the different controls on the form.
2- IsPostBack is a property of the page that is handling the request. In
your example the second page only received data transferred from the first
page but it did not post back yet. This is another reason why you should
have used the first page to handle all functions that require you
determining
whether a page is postback or not.
In summary you would find it much easier to have your ASP.NET web forms
handle their own postback, instead of trying to emulate the ASP model of
posting the form to another web page. It is good to know however that you
can transfer to another page if you needed to.

You might also look up the many samples written on asp.net on the msdn and
will feel comfortable using the Postback to the same page strategy. It
might
help you too if you find a book about Object Oriented Programming to be
able
to utilize the many powerful features of programming the asp.net
environment.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Britney" wrote:
On the second page, I put these code in the page_load section, however,
even if I submit first page, IsPostBack is still FALSE. why?
if (IsPostBack==false)

{

Response.Write("Must going through first page");
}

else

{

......................

}

"Britney" <br**************@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
> Thank you very much..
> Now I think I'm getting better and better on this stuff.
>
> One more question,
> I do not want user to go to secondPage.aspx directly.
> in order to get into second page, user must go through firstPage.aspx
> first (by submitting form)
>
> how do I do that?
>
>
> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
> news:36**********************************@microsof t.com...
>> Hi Britney,
>>
>> If you were to use Server.Transfer ("secondPage.aspx", true); in the
>> first
>> page then you can access the values of the textboxes in the second
>> page
>> using
>> the forms collections, e.g. Request.Form["txtBox1"] would get you the
>> value
>> inside the textbox with the id "txtBox1" that the user entered on the
>> first
>> page.
>> --
>> HTH,
>> Phillip Williams
>> http://www.societopia.net
>> http://www.webswapp.com
>>
>>
>> "Britney" wrote:
>>
>>> okay.. .you're absolutely right..
>>> Now... the reason I want to do "action" in the form originally is
>>> because I
>>> want testing2.aspx receive values of two textboxes from default.aspx
>>> page.
>>> if I do server.redirect, then how can testing2.aspx remember those
>>> values I
>>> entered from prevous page?
>>>
>>>
>>> "Phillip Williams" <Ph**************@webswapp.com> wrote in message
>>> news:AD**********************************@microsof t.com...
>>> > Hi Britney,
>>> >
>>> > Notice that server.transfer does not cause the browser Address line
>>> > to
>>> > change to indicate the new URL (this is probably why you thought it
>>> > did
>>> > not
>>> > work), but if you put any action in the Page_Load of the new page
>>> > you
>>> > will
>>> > realize that the second page is running.
>>> >
>>> > --
>>> > HTH,
>>> > Phillip Williams
>>> > http://www.societopia.net
>>> > http://www.webswapp.com
>>> >
>>> >
>>> > "Britney" wrote:
>>> >
>>> >>
>>> >>
>>> >> I tried the following in my code-behind cs file, but it doesn't
>>> >> work.
>>> >>
>>> >> I don't see it redirect to testing2.aspx..
>>> >>
>>> >> So this is strange, any idea?
>>> >>
>>> >>
>>> >>
>>> >> private void Button1_Click(object sender, System.EventArgs e)
>>> >>
>>> >> {
>>> >>
>>> >>
>>> >> Server.Transfer("testing2.aspx", true);
>>> >>
>>> >>
>>> >>
>>> >> }
>>> >>
>>> >>
>>> >>
>>> >> "Phillip Williams" <Ph**************@webswapp.com> wrote in
>>> >> message
>>> >> news:18**********************************@microsof t.com...
>>> >> > Hi Britney,
>>> >> >
>>> >> > "Cross page postback" is not a feature of ASP.NET 1.x, as you
>>> >> > just
>>> >> > discovered. It is however a feature in ASP.NET 2.0 (currently
>>> >> > in
>>> >> > beta
>>> >> > release) where a button can have a value for a PostBackUrl
>>> >> > property.
>>> >> > You
>>> >> > can
>>> >> > read about this feature on the ASP.NET 2.0 Quickstart tutorials
>>> >> > http://beta.asp.net/QUICKSTART/aspne...s/default.aspx
>>> >> >
>>> >> > Currently, you would have to use Server.Transfer(URL, bool) in
>>> >> > response
>>> >> > for
>>> >> > a ButtonClick event to transfer your form to another page; the
>>> >> > bool
>>> >> > parameter
>>> >> > would determine if want to keep (true) or clear (false) the Form
>>> >> > and
>>> >> > QueryString collections. This link has the full syntax of the
>>> >> > transfer
>>> >> > method:
>>> >> > http://msdn.microsoft.com/library/de...nsfertopic.asp
>>> >> >
>>> >> > --
>>> >> > HTH,
>>> >> > Phillip Williams
>>> >> > http://www.societopia.net
>>> >> > http://www.webswapp.com
>>> >> >
>>> >> >
>>> >> > "Britney" wrote:
>>> >> >
>>> >> >> Hi guys,
>>> >> >> in my default.aspx file, I have following code.
>>> >> >> when I go to browser, I enter values in both textboxs, then I
>>> >> >> hit
>>> >> >> submit
>>> >> >> Button,
>>> >> >> however, it didn't go to page2.aspx. instead, it was still in
>>> >> >> default
>>> >> >> page.
>>> >> >> I thought Action will direct page to page2.aspx, no???
>>> >> >>
>>> >> >>
>>> >> >> <form id="Form1" method="post" runat="server"
>>> >> >> action="page2.aspx">
>>> >> >> <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
>>> >> >> <asp:TextBox id="TextBox2" runat="server"></asp:TextBox>
>>> >> >> <asp:Button id="Button1" runat="server"
>>> >> >> Text="Button"></asp:Button>
>>> >> >> </form>
>>> >> >>
>>> >> >>
>>> >> >>
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>
>


Nov 19 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.