473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ 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.a spx">
<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 1963
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******** ********@TK2MSF TNGP09.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==fa lse)

{

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


}

else

{

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

}

"Britney" <br************ **@yahoo.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
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******** *************** ***********@mic rosoft.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.as px", 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******** *************** ***********@mic rosoft.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(o bject sender, System.EventArg s e)
>>
>> {
>>
>>
>> Server.Transfer ("testing2.aspx ", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph************ **@webswapp.com > wrote in message
>> news:18******** *************** ***********@mic rosoft.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.a spx">
>> >> <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.UrlRefe rrer. 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==fa lse)

{

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

else

{

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

}

"Britney" <br************ **@yahoo.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
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******** *************** ***********@mic rosoft.com...
Hi Britney,

If you were to use Server.Transfer ("secondPage.as px", 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******** *************** ***********@mic rosoft.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(o bject sender, System.EventArg s e)
>>
>> {
>>
>>
>> Server.Transfer ("testing2.aspx ", true);
>>
>>
>>
>> }
>>
>>
>>
>> "Phillip Williams" <Ph************ **@webswapp.com > wrote in message
>> news:18******** *************** ***********@mic rosoft.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.a spx">
>> >> <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******** *************** ***********@mic rosoft.com...
Hi Britney,

Regarding your two questions:

1- you can prevent going to the second page without the first by checking
the Request.UrlRefe rrer. 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==fa lse)

{

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

else

{

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

}

"Britney" <br************ **@yahoo.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
> 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******** *************** ***********@mic rosoft.com...
>> Hi Britney,
>>
>> If you were to use Server.Transfer ("secondPage.as px", 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******** *************** ***********@mic rosoft.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(o bject sender, System.EventArg s e)
>>> >>
>>> >> {
>>> >>
>>> >>
>>> >> Server.Transfer ("testing2.aspx ", true);
>>> >>
>>> >>
>>> >>
>>> >> }
>>> >>
>>> >>
>>> >>
>>> >> "Phillip Williams" <Ph************ **@webswapp.com > wrote in
>>> >> message
>>> >> news:18******** *************** ***********@mic rosoft.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.a spx">
>>> >> >> <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
20936
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 the asp page. When I use _blank target there is no problem, either I use GET or POST method. But when I use _search target, only GET method works.
2
1925
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 server: The security on the site is mainly anonymous. The anonymous account has been changed to an account which has the right permissions. The security on one asp page (GetUser.asp) is changed to only "Windows Integrated". A User that access the...
5
3446
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), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
5
3030
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 need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The payment server then returns to my server with the
5
3116
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 the row. The Delete method marks the row as Deleted in the DataSet or DataTable but does not remove it. Instead when the DataAdapter encounters a row marked as Deleted, it executes its DeleteCommand method to delete the row at the data source. The...
0
9582
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6854
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.