Postback Question

B

Bryan

I've got an ASP.NET application running that has a non-visual user
interface (it's a voice app using VXML.) The voice client understands
cookies and when it requests and aspx page, what actually gets
returned is VXML code. I'd like to be able to postback data to my
page. I can send data with no problem (using VXML submit with method
post) but at the server IsPostBack is always false.

How does the server determine if it is a PostBack? I know there is a
hidden field called ViewState, but if I set that to the current view
state when I create the VXML and allow it to be posted back, it makes
no difference.

Any ideas would be appreciated.

Thanks,
Bryan
 
S

S. Justin Gengo

Bryan,

You could set a viewstate value on page load:

Dim PagePostBack As Boolean = CType(ViewState.Item("PagePostBack"), Bool)

Viewstate.Add("PagePostBack", True)

'---And then on every page load get/check/reset that value.
If PagePostBack Then
'---Page was posted back.
End If


--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
C

clintonG

I have similar problems. It is easy to determine there has been no PostBack.
How for example to force a PostBack when a control's click event is raised
is what I would like to learn.

The 2.0 MasterPages are confusing and FUBAR. When a child control such as a
LinkButton is within a Panel the LinkButton will not PostBack. The controls
disappear from the ViewState. Poof.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
B

Bryan

Justin -
It looks like my ViewState is not being maintained across calls. I
added this code to the PageLoad method:

Object o = this.ViewState["PagePostBack"];
if(o == null){
Logger.Write("First time");
this.ViewState["PagePostBack"] = true;
}else{
bool b = (bool)this.ViewState["PagePostBack"];
Logger.Write("Not null: " + b);
}

I always see the first log message. Just FYI this is .NET 1.1. Why
would the view state be getting reset?

Thanks,
Bryan
 
B

Bruce Barker

the server knows its a postback by checking if viewstate is not null and
valid. this changes the logic of the current page processing cycle, casing
the loadpostbackdata event to fire (which is how asp.net control get their
postback values). for security the viewstate is encrypted, and checked on
postback, so you have to send a viewstate that matches the page.

-- bruce (sqlwork.com)
 
J

JIMCO Software

Bruce said:
the server knows its a postback by checking if viewstate is not null
and valid. this changes the logic of the current page processing
cycle, casing the loadpostbackdata event to fire (which is how
asp.net control get their postback values). for security the
viewstate is encrypted, and checked on postback, so you have to send
a viewstate that matches the page.

Bruce,

ASP.NET actually uses two different methods to determine if we're in a
postback. First it checks to see if the Request.Forms is null. If it is,
IsPostBack is false. Otherwise, it checks the _fPageLayoutChanged property
which tells us whether or not the control tree has changed. If this is
true, IsPostBack will evaluate to false. The value of viewstate is actually
not used other than as a part of the forms collection.

Just as an aside, viewstate is actually Base64 encoded and not encrypted.
:)

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 
S

S. Justin Gengo

Ahhh, so if we solve this then the normal IsPostBack will probably work and
you won't have to create your own.

I've never done any voice applications, so I don't know if it will act
differently. Normally though there is a ViewState property of the page to
set using viewstate to true or false. The first thing I'd do is make certain
that is set to true.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Bryan said:
Justin -
It looks like my ViewState is not being maintained across calls. I
added this code to the PageLoad method:

Object o = this.ViewState["PagePostBack"];
if(o == null){
Logger.Write("First time");
this.ViewState["PagePostBack"] = true;
}else{
bool b = (bool)this.ViewState["PagePostBack"];
Logger.Write("Not null: " + b);
}

I always see the first log message. Just FYI this is .NET 1.1. Why
would the view state be getting reset?

Thanks,
Bryan



Bryan,

You could set a viewstate value on page load:

Dim PagePostBack As Boolean = CType(ViewState.Item("PagePostBack"), Bool)

Viewstate.Add("PagePostBack", True)

'---And then on every page load get/check/reset that value.
If PagePostBack Then
'---Page was posted back.
End If
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top