Why it is always: this.IsPostBack = false?

G

Guest

Hello, friends,

Help please, this has driven me nuts:

I am developing the default.aspx page. In this page, we allow a user to type
user name/password, and then click on Submit button to login.

<form name="form1" onsubmit="return isValidInput()" action="default.aspx"
method="post">
.....
<INPUT type="submit" value="Submit" id="submit">
</form>

In Page_Load(), we have a statement to check if this is a postback:

If (this.IsPostBack)
//verifying login info and direct to proper page
else
//display default page

However, for some reason, this.IsPostBack was always false, no matter it was
the first time to view default.aspx from IE or after a user typed a valid
user name/pswd and clicked on Submit button.

Any ideas?

Thanks a lot.
 
K

Kevin Lawrence

Hello, friends,
Help please, this has driven me nuts:

I am developing the default.aspx page. In this page, we allow a user
to type user name/password, and then click on Submit button to login.

<form name="form1" onsubmit="return isValidInput()"
action="default.aspx"
method="post">
....
<INPUT type="submit" value="Submit" id="submit">
</form>
In Page_Load(), we have a statement to check if this is a postback:

If (this.IsPostBack)
//verifying login info and direct to proper page
else
//display default page
However, for some reason, this.IsPostBack was always false, no matter
it was the first time to view default.aspx from IE or after a user
typed a valid user name/pswd and clicked on Submit button.

Any ideas?

Thanks a lot.

I'm not 100% but have you tried using the Server Button control instead?

Kev
 
S

sloan

You need to drag the <asp:button> onto your form.

NOT the html control "submit button"

...

What you don't see is that with the <asp:button>.... ASP.NET is wiring up a
bunch of events for you.

DRAG and DROP the button, don't try to create it by handtyping.
 
J

Juan T. Llibre

Instead of :
<form name="form1" onsubmit="return isValidInput()" action="default.aspx"
method="post">

Try :

<form id="form1" onsubmit="return isValidInput()" runat="server" action="default.aspx"
method="post">

( You are missing the "runat" attribute...)



Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
J

Juan T. Llibre

That would be advisable, too, but the main problem is
that his form didn't have the runat="server" attribute.



Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 
G

Guest

you are absolutely right. thank you.

Juan T. Llibre said:
Instead of :
<form name="form1" onsubmit="return isValidInput()" action="default.aspx"
method="post">

Try :

<form id="form1" onsubmit="return isValidInput()" runat="server" action="default.aspx"
method="post">

( You are missing the "runat" attribute...)



Juan T. Llibre
ASP.NET MVP
ASPNETFAQ.COM : http://www.aspnetfaq.com
==================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top