473,788 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1891
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*********@no spam.thanx> wrote in message
news:IP******** ******@nospamth ankyou.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*********@no spam.thanx> wrote in message
news:IP******** ******@nospamth ankyou.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*********@no spam.thanx> wrote in message
news:IP******* *******@nospamt hankyou.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*********@no spam.thanx> wrote in message
news:IP******** ******@nospamth ankyou.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*********@no spam.thanx> wrote in message
news:IP******** ******@nospamth ankyou.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*********@no spam.thanx> wrote in message
news:$A******** ******@nospamth ankyou.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
3064
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 data at the same time. (To take them back to an html page showing a form that needs correcting because some data is missing.) I believe this is either tricky or not possible from what I've seen, but I'd just like to see what others think...
0
1848
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 the other but not both. The child page (html) code is: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="AddKeyWord.aspx.vb" Inherits="ComponentSearch.AddKeyWord"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML>...
4
2950
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
1202
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 submit button). If I try to GET a page after timeout (i.e. just picking a page to visit from a menu), I am redirected to the login screen properly. The browser error I'm getting in the POST example is "403.1 Execute Access Forbidden". I...
2
8925
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 asp.net 1.x will not pick up the button click event. Instead, it monitors the on submit event of the form and the _doPostBack event of the asp.net page. It overrides the _doPostBack and onsubmit events and checks whether the page has already...
17
1649
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
1453
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 v.1.1. This seems like such a COMMON thing, I can't imagine that there isn't a SIMPLE way to do this.... Thanks for your help,
13
2848
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 application (either 1.1 or 2.0)? What was the source of your information? Thank you.
0
1354
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 page. I've tried to do this using HttpWebRequest and HttpWebResponse, Passing the CookieContainer from one to another in order to maintain session consistency. Unfortunately, the page re-renderes at the second step, as if i just loaded it for the...
0
10364
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
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
9967
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
8993
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...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.