Lose state information when using __doPostBack from Javascript

A

Adrian

I appear to be losing ViewState information when calling the
__doPostBack function.

I am attempting to use the showModalDialog to load a new web page
which confirms that a user wishes to save a query.

The showModalDailog returns a value to the original page which is used
as a parameter in __doPostback, in turn trapped by the Page_Load
procedure and processed.

This all seems to work with the exception that I appear to be losing
state information on all the page controls as if I had refreshed the
page.

Any help or pointers would be greatly appreciated, below is the main
parts of the code. If I comment out the __doPostback state
information is not lost.



Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click

If qryFields.SaveQueryExists() Then
PopupWindowConfirmSave()
Else
qryFields.Save()
End If

End Sub

' --------------------------------------


Private Sub PopupWindowConfirmSave()

Dim jscript As System.Text.StringBuilder = New
System.Text.StringBuilder()

jscript.Append("<script language=""Javascript"">")
jscript.Append("OpenChild();")
jscript.Append("</script>")
RegisterClientScriptBlock("popup", jscript.ToString)

End Sub

' ---------------------------------------

' Javascript Function - doesn't lose state information
' if the __doPostback is commented out


function OpenChild()
{
var WinSettings =
"center:yes;resizable:no;dialogHeight:150px;dialogWidth:350px;status:no"
var RetVal = window.showModalDialog("Confirmation.htm","",
WinSettings);

if (RetVal == null)
{
window.alert("Save cancelled")
}
else
{
if (RetVal = "YES")
{
__doPostBack('','@Custom1')
}
else
{
__doPostBack('','@Custom2')
}
}
}
 
A

Adrian

In case anyone was interested, the problem was that I used
RegisterClientScriptBlock as opposed to RegisterStartupScript,
changing this resolved the problem :)
 

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,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top