Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > If Not Page.IsPostBack Then <-- HELP!!!

Reply
Thread Tools

If Not Page.IsPostBack Then <-- HELP!!!

 
 
luna
Guest
Posts: n/a
 
      01-27-2004
If Not Page.IsPostBack Then
surname1.Text = "PASS"
Else
surname1.Text = "FAIL"
End If

Im new to aspx so apologies in advance

Im using the above piece of code to try to ascertain what is happening with
my webpage

I created a webpage and put a button on it - simple enough

when i click the button i want to retrieve some data from a SQL database and
put it into different textboxes - seems simple enough

the above 5 lines of code is my code behind my button
Now surname1.text is never equal to PASS - why i dont know?

if i dont include if not page.ispostback then
the code seems to work - except that i cannot run any SQL commands on the
DB

any help again is greatly appreciated

Mark.


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      01-27-2004
if this is in the button_click event then it's ALWAYS a post back, you are
saying "IF NOT", but that will always indicate "false"

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com


"luna" <> wrote in message
news:2BvRb.444$...
> If Not Page.IsPostBack Then
> surname1.Text = "PASS"
> Else
> surname1.Text = "FAIL"
> End If
>
> Im new to aspx so apologies in advance
>
> Im using the above piece of code to try to ascertain what is happening

with
> my webpage
>
> I created a webpage and put a button on it - simple enough
>
> when i click the button i want to retrieve some data from a SQL database

and
> put it into different textboxes - seems simple enough
>
> the above 5 lines of code is my code behind my button
> Now surname1.text is never equal to PASS - why i dont know?
>
> if i dont include if not page.ispostback then
> the code seems to work - except that i cannot run any SQL commands on

the
> DB
>
> any help again is greatly appreciated
>
> Mark.
>
>



 
Reply With Quote
 
 
 
 
Scott Allen
Guest
Posts: n/a
 
      01-27-2004
A button press causes your form to post back to the server, thus
IsPostBack will always be true when an event happens.

Is this code in Page_Load or some other event handler? If you show us
the code you are trying to use to execute SQL commands I'm sure
someone will be able to help you.

--
Scott
http://www.OdeToCode.com

On Tue, 27 Jan 2004 15:38:12 -0000, "luna" <> wrote:

>If Not Page.IsPostBack Then
> surname1.Text = "PASS"
>Else
> surname1.Text = "FAIL"
>End If
>
>Im new to aspx so apologies in advance
>
>Im using the above piece of code to try to ascertain what is happening with
>my webpage
>
>I created a webpage and put a button on it - simple enough
>
>when i click the button i want to retrieve some data from a SQL database and
>put it into different textboxes - seems simple enough
>
>the above 5 lines of code is my code behind my button
>Now surname1.text is never equal to PASS - why i dont know?
>
>if i dont include if not page.ispostback then
>the code seems to work - except that i cannot run any SQL commands on the
>DB
>
>any help again is greatly appreciated
>
>Mark.
>


 
Reply With Quote
 
Cristhian Job
Guest
Posts: n/a
 
      01-27-2004
Whenever you enter the page, you are in the NOT ISPOSTBACK, so since the
first time that you click the button, you´ll be in a POSTBACK...

The condition If not IsPostBack is used in the Page_Load, usually to fill
controls and other actions that should only be performed once...

Cristhian,
Mx

"luna" <> escribió en el mensaje
news:2BvRb.444$...
> If Not Page.IsPostBack Then
> surname1.Text = "PASS"
> Else
> surname1.Text = "FAIL"
> End If
>
> Im new to aspx so apologies in advance
>
> Im using the above piece of code to try to ascertain what is happening

with
> my webpage
>
> I created a webpage and put a button on it - simple enough
>
> when i click the button i want to retrieve some data from a SQL database

and
> put it into different textboxes - seems simple enough
>
> the above 5 lines of code is my code behind my button
> Now surname1.text is never equal to PASS - why i dont know?
>
> if i dont include if not page.ispostback then
> the code seems to work - except that i cannot run any SQL commands on

the
> DB
>
> any help again is greatly appreciated
>
> Mark.
>
>



 
Reply With Quote
 
luna
Guest
Posts: n/a
 
      01-27-2004
hi,

thanks for the help - not sure exactly what i did but its working now - just
tried lots of things till it worked!
i just got rid of the ispostback statement and it was fine (i originally got
a asp code example - had to make a
few changes for aspx with code behind)

thanks

mark



"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:...
> A button press causes your form to post back to the server, thus
> IsPostBack will always be true when an event happens.
>
> Is this code in Page_Load or some other event handler? If you show us
> the code you are trying to use to execute SQL commands I'm sure
> someone will be able to help you.
>
> --
> Scott
> http://www.OdeToCode.com
>
> On Tue, 27 Jan 2004 15:38:12 -0000, "luna" <> wrote:
>
> >If Not Page.IsPostBack Then
> > surname1.Text = "PASS"
> >Else
> > surname1.Text = "FAIL"
> >End If
> >
> >Im new to aspx so apologies in advance
> >
> >Im using the above piece of code to try to ascertain what is happening

with
> >my webpage
> >
> >I created a webpage and put a button on it - simple enough
> >
> >when i click the button i want to retrieve some data from a SQL database

and
> >put it into different textboxes - seems simple enough
> >
> >the above 5 lines of code is my code behind my button
> >Now surname1.text is never equal to PASS - why i dont know?
> >
> >if i dont include if not page.ispostback then
> >the code seems to work - except that i cannot run any SQL commands on

the
> >DB
> >
> >any help again is greatly appreciated
> >
> >Mark.
> >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow, then quick then slow JosephByrns ASP .Net 4 11-13-2007 01:34 AM
Help. SessionID is x then y then x then y BodiKlamph@gmail.com ASP General 0 09-03-2005 03:02 PM
Read all of this to understand how it works. then check around on otherRead all of this to understand how it works. then check around on other thelisa martin Computer Support 2 08-18-2005 06:40 AM
greater then / less then =?Utf-8?B?TWlrZQ==?= ASP .Net 2 11-04-2004 06:05 PM
Help: anyway to burn movie to DVD RW (then view it) and then eraseafterward? qwerty DVD Video 6 01-07-2004 04:54 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57