EDN Admin
Well-known member
Hi,
I am working in a scenario where on clicking on close button in popup window, the pagemethod present in the parent window is executed from javascript of parent window.
The strange thing happening is that the page method is executed exactly for five time i.e., if the open and close the popup for five times the page method is executed well and for the 6th time, the break poing set to the page method is not hit at all...!
After 3-4 min. the onerror handler in the parent window is hit and the error message is The Server method ListTargetLocations failed with _statusCode 12002. There were very few google results and none solved my issue
The code in the popup window and parent window goes something like this.
Am I missing something?? Why would the call to pagemethod fail after executing successfully for few times? Please somebody help me in this...
<span style="text-decoration:underline popup.aspx
<pre class="prettyprint <script>
function Unload()
{
if(window.opener != null)
{
window.opener.ReadConcatinatedSourceString(document.getElementById(hdnTagTypeID).value);
return false;
}
}
</script>
<body onunload="return Unload();
<form id="form1" runat="server
</form>
</body>[/code]
<br/>
<span style="font-size:small <span style="font-size:small <span style="font-size:small SampleParent.aspx
<pre class="prettyprint <script language=javascript>
function ReadConcatinatedSourceString(val)
{
PageMethods.ListTargetLocations(document.getElementById(hdnArticleID).value, jQuerySucceeded, onerror);
}
function jQuerySucceeded(result) {
-- some code on success
}
function onerror(error) {
alert(error.message); // server method failed
// status code = 12002
}
</script>
<body><form>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true
<!--- many many controls here but not related to my error causing functionality-->
</form>
</body>[/code]
<br/>
SampleParent.aspx.vb
<pre class="prettyprint <WebMethod()> _
Shared Function ListTargetLocations(ByVal sArticleID As String) As String
Dim temp As String = "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
Dim SQL As String = "execute SPXYZ @ArticleID=" & sArticleID & ""
Dim rs As New Database.DataReader
If rs.Open(SQL) Then
Do While rs.Data.Read
temp += "<tr><td valign=top>" & rs.Data("Name") & "</td>"
temp += "<td width=16><img src=""images/delete.gif"" style=""border-width:0px; cursor
ointer;"" OnClick=""if (confirm(Do you really want to delete this target?)) {document.forms[1].DelLocation.value=" & rs.Data("Name").ToString & ";}"" /></td></tr>"
Loop
End If
temp += "</table>"
temp += "<input type=""hidden"" name=""DelLocation" "
Return temp
End Function[/code]
<br/>
I commented out the db code to check if the problem is network issue/ db issue. but yet the pagemethod is not working after 5 times![Frown :( :(](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f641.png)
View the full article
I am working in a scenario where on clicking on close button in popup window, the pagemethod present in the parent window is executed from javascript of parent window.
The strange thing happening is that the page method is executed exactly for five time i.e., if the open and close the popup for five times the page method is executed well and for the 6th time, the break poing set to the page method is not hit at all...!
After 3-4 min. the onerror handler in the parent window is hit and the error message is The Server method ListTargetLocations failed with _statusCode 12002. There were very few google results and none solved my issue
The code in the popup window and parent window goes something like this.
Am I missing something?? Why would the call to pagemethod fail after executing successfully for few times? Please somebody help me in this...
<span style="text-decoration:underline popup.aspx
<pre class="prettyprint <script>
function Unload()
{
if(window.opener != null)
{
window.opener.ReadConcatinatedSourceString(document.getElementById(hdnTagTypeID).value);
return false;
}
}
</script>
<body onunload="return Unload();
<form id="form1" runat="server
</form>
</body>[/code]
<br/>
<span style="font-size:small <span style="font-size:small <span style="font-size:small SampleParent.aspx
<pre class="prettyprint <script language=javascript>
function ReadConcatinatedSourceString(val)
{
PageMethods.ListTargetLocations(document.getElementById(hdnArticleID).value, jQuerySucceeded, onerror);
}
function jQuerySucceeded(result) {
-- some code on success
}
function onerror(error) {
alert(error.message); // server method failed
// status code = 12002
}
</script>
<body><form>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true
<!--- many many controls here but not related to my error causing functionality-->
</form>
</body>[/code]
<br/>
SampleParent.aspx.vb
<pre class="prettyprint <WebMethod()> _
Shared Function ListTargetLocations(ByVal sArticleID As String) As String
Dim temp As String = "<table width=""100%"" border=0 cellpadding=0 cellspacing=0>"
Dim SQL As String = "execute SPXYZ @ArticleID=" & sArticleID & ""
Dim rs As New Database.DataReader
If rs.Open(SQL) Then
Do While rs.Data.Read
temp += "<tr><td valign=top>" & rs.Data("Name") & "</td>"
temp += "<td width=16><img src=""images/delete.gif"" style=""border-width:0px; cursor
![Stick out tongue :p :p](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f61b.png)
Loop
End If
temp += "</table>"
temp += "<input type=""hidden"" name=""DelLocation" "
Return temp
End Function[/code]
<br/>
I commented out the db code to check if the problem is network issue/ db issue. but yet the pagemethod is not working after 5 times
![Frown :( :(](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f641.png)
View the full article