[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Is an AutoPostBack field required?

Craig Deelsnyder

4/2/2002 1:00:00 AM

I've been working on a problem with a page of mine that will not post back
to itself. Originally I thought it was related to forms authentication (in
a previous post I had), but now it looks like a different problem.

I have an app. with a custom logon page. A simple logon, with two text
fields for user id and password, and a logon button. One other thing is I'm
trying to use these pages on a handheld, so I had to override two methods in
my pages to get the pages to display correctly:

Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As
Object)
Session("MyViewState") = viewState
End Sub

Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
Return Session("MyViewState")
End Function

When I override these two methods, the page (HTML in the browser) does not
load with any JavaScript to do a postback when you click the submit button.
There's no __doPostBack() fxn in the page. So when you do hit submit, it
just reloads the page (my logic in the button_click does not run, and the
action="the page" so my page_load just runs).

To get it to submit, I either have to:
- stop overriding these methods (I have to override them, though!)
- add or make one of my fields AutoPostBack=true and then it works fine.
From my business design, I don't need to autopostback for either one right
now. So adding that condition to one field just introduces an extra server
hit (and could confuse other developers).

So does this mean that I have to have at least one AutoPostBack field on a
form for it to submit properly? All of my other pages have at least one
field that does, and they have worked fine from day one. The logon page
broke the minute I overrode those methods.

Thanks!
Craig



2 Answers

Matthew White

4/2/2002 9:34:00 AM

0

In the methods your are overriding try calling the parents method of the
same name

ie
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As
Object)
Mybase.SavePageStateToPersistanceMedium(viewstate)
Session("MyViewState") = viewState
End Sub
'so that you don't miss out on any of the functionality of the lower level
baseclass while still being able to do what you need, I havn't tried this
myself but i'm pritty sure this is what the problem would be.

--
Matthew White
Programmer Analyst
Theta Technologies Pty Ltd

Ph: +61 7 3899 6422
Fax: +61 7 3899 6411
Mobile: 0409 622 742
Email: mattheww@thetatechnologies.com.au

"Craig Deelsnyder" <cdeelsny@yahoo.com> wrote in message
news:#JgzbBd2BHA.2272@tkmsftngp07...
> I've been working on a problem with a page of mine that will not post back
> to itself. Originally I thought it was related to forms authentication
(in
> a previous post I had), but now it looks like a different problem.
>
> I have an app. with a custom logon page. A simple logon, with two text
> fields for user id and password, and a logon button. One other thing is
I'm
> trying to use these pages on a handheld, so I had to override two methods
in
> my pages to get the pages to display correctly:
>
> Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState
As
> Object)
> Session("MyViewState") = viewState
> End Sub
>
> Protected Overrides Function LoadPageStateFromPersistenceMedium() As
Object
> Return Session("MyViewState")
> End Function
>
> When I override these two methods, the page (HTML in the browser) does not
> load with any JavaScript to do a postback when you click the submit
button.
> There's no __doPostBack() fxn in the page. So when you do hit submit, it
> just reloads the page (my logic in the button_click does not run, and the
> action="the page" so my page_load just runs).
>
> To get it to submit, I either have to:
> - stop overriding these methods (I have to override them, though!)
> - add or make one of my fields AutoPostBack=true and then it works fine.
> From my business design, I don't need to autopostback for either one right
> now. So adding that condition to one field just introduces an extra
server
> hit (and could confuse other developers).
>
> So does this mean that I have to have at least one AutoPostBack field on a
> form for it to submit properly? All of my other pages have at least one
> field that does, and they have worked fine from day one. The logon page
> broke the minute I overrode those methods.
>
> Thanks!
> Craig
>
>
>


Craig Deelsnyder

4/2/2002 5:29:00 PM

0

There is no such method available on MyBase from within my method. BTW, I
am inheriting from System.Web.UI.Page.

Plus I would not want to run MyBase's method of saving persistence, as the
way it does save (in hidden fields) causes errors on handhelds (which of
course is why I'm overriding the method).

Thanks, though...


"Matthew White" <mattheww@thetatechnologies.com.au> wrote in message
news:uqjyQih2BHA.2392@tkmsftngp07...
> In the methods your are overriding try calling the parents method of the
> same name
>
> ie
> Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState
As
> Object)
> Mybase.SavePageStateToPersistanceMedium(viewstate)
> Session("MyViewState") = viewState
> End Sub
> 'so that you don't miss out on any of the functionality of the lower level
> baseclass while still being able to do what you need, I havn't tried this
> myself but i'm pritty sure this is what the problem would be.
>
> --
> Matthew White
> Programmer Analyst
> Theta Technologies Pty Ltd
>
> Ph: +61 7 3899 6422
> Fax: +61 7 3899 6411
> Mobile: 0409 622 742
> Email: mattheww@thetatechnologies.com.au
>
> "Craig Deelsnyder" <cdeelsny@yahoo.com> wrote in message
> news:#JgzbBd2BHA.2272@tkmsftngp07...
> > I've been working on a problem with a page of mine that will not post
back
> > to itself. Originally I thought it was related to forms authentication
> (in
> > a previous post I had), but now it looks like a different problem.
> >
> > I have an app. with a custom logon page. A simple logon, with two text
> > fields for user id and password, and a logon button. One other thing is
> I'm
> > trying to use these pages on a handheld, so I had to override two
methods
> in
> > my pages to get the pages to display correctly:
> >
> > Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState
> As
> > Object)
> > Session("MyViewState") = viewState
> > End Sub
> >
> > Protected Overrides Function LoadPageStateFromPersistenceMedium() As
> Object
> > Return Session("MyViewState")
> > End Function
> >
> > When I override these two methods, the page (HTML in the browser) does
not
> > load with any JavaScript to do a postback when you click the submit
> button.
> > There's no __doPostBack() fxn in the page. So when you do hit submit,
it
> > just reloads the page (my logic in the button_click does not run, and
the
> > action="the page" so my page_load just runs).
> >
> > To get it to submit, I either have to:
> > - stop overriding these methods (I have to override them, though!)
> > - add or make one of my fields AutoPostBack=true and then it works fine.
> > From my business design, I don't need to autopostback for either one
right
> > now. So adding that condition to one field just introduces an extra
> server
> > hit (and could confuse other developers).
> >
> > So does this mean that I have to have at least one AutoPostBack field on
a
> > form for it to submit properly? All of my other pages have at least one
> > field that does, and they have worked fine from day one. The logon page
> > broke the minute I overrode those methods.
> >
> > Thanks!
> > Craig
> >
> >
> >
>
>