473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Can I have GET and POST forms on the same page?

Hello,

From my limited experience with ASP.NET (couple of weeks so far, much
time wasted with stupid book), you can only have one form per page. If
so, how do you handle the scenario where you want two forms (from the
user's point of view) on a page, one form that uses POST and one that
uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However,
search engines on sites generally use GET as this makes bookmarking the
page easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
9 1877
Typically, in ASP.NET each form just posts to itself. This is called a
postback. Every form can process it's own information, you do not post to
another page, as you did in ASP.

In Page_Load you can check the IsPostBack property to see if the page is
running as a result of a postback.

Additionally, since everything is completely OO, a button is an object on
the server with events. So you can handle the click even of a particular
button by writing a handler for its Click event.

"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IP**************@nospamthankyou.spam...
Hello,

From my limited experience with ASP.NET (couple of weeks so far, much time
wasted with stupid book), you can only have one form per page. If so, how
do you handle the scenario where you want two forms (from the user's point
of view) on a page, one form that uses POST and one that uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However, search
engines on sites generally use GET as this makes bookmarking the page
easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)


Nov 19 '05 #2
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one at
a time.
Or you can have more than one form visible on your page at a time, but only
one of them can be a server form (i.e. with the runat=server attribute.)
Server forms only support posting back to themselves (not to other pages.)

This will all become more flexible in .NET version 2.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IP**************@nospamthankyou.spam...
Hello,

From my limited experience with ASP.NET (couple of weeks so far, much time
wasted with stupid book), you can only have one form per page. If so, how
do you handle the scenario where you want two forms (from the user's point
of view) on a page, one form that uses POST and one that uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However, search
engines on sites generally use GET as this makes bookmarking the page
easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #3
>Typically, in ASP.NET each form just posts to itself. This is called a
postback. Every form can process it's own information, you do not post to
another page, as you did in ASP.
Thanks, I understand this, but you still sometimes want to post to
another page. A log-in form that appears on every page is a good
example. You wouldn't bother adding the log-in code to every page, just
have one page to handle it.

Anyway, this doesn't really answer the question. Even if you were to
post the log-in back to the same page, you would still want the log-in
to use POST and the search engine to use GET. That was the point of my
question.
In Page_Load you can check the IsPostBack property to see if the page is
running as a result of a postback.

Additionally, since everything is completely OO, a button is an object on
the server with events. So you can handle the click even of a particular
button by writing a handler for its Click event.
Thanks, I understand these points as well, but don't see how they relate
t my question.

Thanks for the reply, but I'm still not clear. I am asking specifically
about using POST and GET on the same page.
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IP**************@nospamthankyou.spam...
Hello,

From my limited experience with ASP.NET (couple of weeks so far, much time
wasted with stupid book), you can only have one form per page. If so, how
do you handle the scenario where you want two forms (from the user's point
of view) on a page, one form that uses POST and one that uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However, search
engines on sites generally use GET as this makes bookmarking the page
easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #4
You can only have one (ASP.Net) WEBFORM on a page. This doesn't mean that
you can't have more than one HTML form on a page. In fact, you can add as
many HTML forms to the page as you wish.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IP**************@nospamthankyou.spam...
Hello,

From my limited experience with ASP.NET (couple of weeks so far, much time
wasted with stupid book), you can only have one form per page. If so, how
do you handle the scenario where you want two forms (from the user's point
of view) on a page, one form that uses POST and one that uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However, search
engines on sites generally use GET as this makes bookmarking the page
easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #5
Place your member's login in a user control that is placed on the top of
every page. You an handle the "login" button click in the UserControl.

You will only have to code it once.

bill

"Alan Silver" <al*********@nospam.thanx> wrote in message
news:IP**************@nospamthankyou.spam...
Hello,

From my limited experience with ASP.NET (couple of weeks so far, much
time wasted with stupid book), you can only have one form per page. If
so, how do you handle the scenario where you want two forms (from the
user's point of view) on a page, one form that uses POST and one that
uses GET?

For example, suppose your site has a members' log-in form at the top of
every page. This would normally use POST as you don't want the password
appearing in the URL where it can be seen in the history. However,
search engines on sites generally use GET as this makes bookmarking the
page easy.

Can you do this? If not, is there any way around it?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #6
>You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one at
a time.
Or you can have more than one form visible on your page at a time, but only
one of them can be a server form (i.e. with the runat=server attribute.)
Server forms only support posting back to themselves (not to other pages.)
Ah, so the search form would be a server form, and the log-in form would
be a standard old HTML form. Clever. I guess without the self-posting
stuff (which you wouldn't have as the log-in form posts to another
page), you don't need the ASP.NET bits.

Thanks, that helps a lot.
This will all become more flexible in .NET version 2.


In what way? just interested as, given that I am learning from scratch,
I am trying to do things the 2.0 way from the start as it will save
relearning later. I reckon by the time I'm ready to roll out a
production ASP.NET site, 2.0 will be out of beta.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #7
>You can only have one (ASP.Net) WEBFORM on a page. This doesn't mean that
you can't have more than one HTML form on a page. In fact, you can add as
many HTML forms to the page as you wish.


Thanks Kevin, you and Juan both gave the same answer ;-) I'm a lot
clearer now thanks to you two.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #8
Well, for starters, in ASP.NET 2.0 you'll be able to have your server forms
post to other pages.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:$A**************@nospamthankyou.spam...
You can only have one visible server form on the page at a time.
So you could have more than one server form as long as you only show one
at
a time.
Or you can have more than one form visible on your page at a time, but
only
one of them can be a server form (i.e. with the runat=server attribute.)
Server forms only support posting back to themselves (not to other pages.)


Ah, so the search form would be a server form, and the log-in form would
be a standard old HTML form. Clever. I guess without the self-posting
stuff (which you wouldn't have as the log-in form posts to another page),
you don't need the ASP.NET bits.

Thanks, that helps a lot.
This will all become more flexible in .NET version 2.


In what way? just interested as, given that I am learning from scratch, I
am trying to do things the 2.0 way from the start as it will save
relearning later. I reckon by the time I'm ready to roll out a production
ASP.NET site, 2.0 will be out of beta.

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #9
>Well, for starters, in ASP.NET 2.0 you'll be able to have your server forms
post to other pages.


Oh, clever stuff. I saw a post here earlier that reckoned 2.0 wasn't due
until the end of the year. I hope I'll be doing this properly long
before that!! Looks like I'll be learning 1.1 after all.

Thanks for the reply

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Alex Hunsley | last post by:
A question that has certainly been asked before and I've googled etc. for answers with no certain outcome... I'd like my PHP script to redirect the client browser to another page, POSTing some...
0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
4
by: VB Programmer | last post by:
Can someone provide a simple explanation on the difference between the GET and POST methods? What are the adv/disadv of both and when should I use them? Thanks.
0
by: Ed Henn | last post by:
I'm having a problem with .NET Forms Authentication in a particular application. It's not redirecting properly when my session is timed out, seemingly only when I POST the page (i.e. click a form...
2
by: Ghafran Abbas | last post by:
Call this function from the Page_OnLoad event of your asp.net page. This will prevent the user from doing multiple post backs or button clicks. This was designed to not disable the button, because...
17
by: Justin | last post by:
How do I post a form to a specified url using an ASP.NET with a code behind? With traditional ASP I used to be able to simply use: action="https://www.domain.com/process.asp" Thanks, Justin.
9
by: Greg Stevens | last post by:
How do I specify that I want the data in a form to post to a DIFFERENT document? I've come across the Button.PostBackUrl property, but it is available in ASP.NET v. 2.0 only, and I'm using...
13
by: Thom Little | last post by:
I have an HTML Form that uses GET and is processed by an ASP.NET 1.1 web application. Can you recommend a simple example of an HTML Form that uses POST and is processed by an ASP.NET web...
0
by: YATTT | last post by:
Hello, I've been trying for some time now, to post some information to a SSL web page, when the first step is getting the page, and the second step is filling the form and posting to the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.