473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Lose state information when using __doPostBack from Javascript

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;dialog Width: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')
}
}
}
Nov 18 '05 #1
1 2465
In case anyone was interested, the problem was that I used
RegisterClientScriptBlock as opposed to RegisterStartupScript,
changing this resolved the problem :)
ap*********@hotmail.com (Adrian) wrote in message news:<99*************************@posting.google.c om>...
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;dialog Width: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')
}
}
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Jaffe | last post by:
I've seen a few posts on this topic, but still haven't found a clean solution. Anyone have other suggestions or feel that one of the options I highlight below is the way to go? The Problem...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
10
by: mwieder | last post by:
I've got an ASP.NET form with a textbox and a customvalidator. The form inherits from a base wizard class with back, next and cancel buttons. The CausesValidation property of the Cancel button...
2
by: Rob Roberts | last post by:
Is there any way to prevent a ButtonField in a GridView from doing a postback when clicked? I want to use my own onclick handler to call window.open('SomePage.aspx') to display a page in a new...
1
by: Philip | last post by:
I am attempting to use the ASP.NET generated __doPostBack JavaScript function in my custom JavaScript and I can use it successfully but only after the web page is loaded and idle. I prefer to...
1
by: Jeff | last post by:
I need to place a "Previous Page" link on every page within my site and a simple javascript:history.back() will not work because I need it to capture the state of the page when I left it. For...
1
by: APA | last post by:
Well, I've figured out a way around this mess. I have no idea why it doesn't work the way I think it should but I do know how to get it to work. The scenario is that I have a form that has one...
1
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have...
0
by: codeshelp | last post by:
I have a gridview that has a ButtonField(Insert) that calls a detailsview which allows you to insert data to the gridview. The postback for this buttonField is:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.