473,473 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

method post problem

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
12 1930
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
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


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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
2
by: Asp Help | last post by:
I'm working on a ASP applicatition to create Windows 2000 users. Because I don't want everybody to have access to the site I've changed te security in IIS 5.0 which runs on a windows 2000 Sp4...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.