473,786 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wierd Behavior of __doPostBack

Hello,

I am having some weird behavior between two machines...one
which is running the 1.1 framework and one which is
running 1.0. After opening a child form from a parent...I
update the database then call the __doPostBack function of
the window.opener. This has been working like a charm for
the last several months. Our ISP where we run the .NET app
recently upgraded to 1.1 of the framework. When I run my
app at the ISP...the __doPostBack function in the
window.opener dies with an "Undefined is not an object or
is NULL" message on this line:

theform.__EVENT TARGET.value = eventTarget.spl it("$").join
(":");

I have enclosed the entire __doPostBack function below.

I DO NOT get this error when running on my development
machine...anyon e have any ideas at all...I am at a loss.
When I deploy I am compiling against the 1.0
framework...so can't see how...even if the ISP is running
1.1 as well...that it would matter.

Paul

!--
function __doPostBack(ev entTarget, eventArgument) {
var theform;
if (window.navigat or.appName.toLo werCase
().indexOf("net scape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENT TARGET.value =
eventTarget.spl it("$").join(": ");
theform.__EVENT ARGUMENT.value =
eventArgument;
theform.submit( );
}
Nov 17 '05 #1
1 6809
Hello Paul,
The way you are implementing the postback is highly not recommended.

This is accomplished by using two methods:
- RegisterClientS criptBlock
- GetPostBackEven tReference

RegisterClientS criptBlock allows ASP.NET server controls to emit
client-side script blocks in the Page.
The client-side script is emitted just after the opening tag of the Page
object's <form runat= server> element.The script block is
emitted as the object that renders the output is defined, so you must
include both tags of the <script> element.

Please refers to the following documentation regarding
RegisterClientS criptBlock
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebU IPageClassRegis terClientScript BlockTopic.asp
GetPostBackEven tReference obtains a reference to a client-side script
function that causes, when invoked, the server to post back to the page.

Please refers to the following documentation regarding
GetPostBackEven tReference
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebu ipageclassgetpo stbackeventrefe rencetopic.asp

I am including below the sample where the DropDown List Click Client Event
will Post to the server and then a call a server side code.

===============
WebForm1.aspx
===============
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Web Form1.aspx.vb" Inherits="Custo merDemosVB.WebF orm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft Visual Studio.NET 7.0">
<meta name="CODE_LANG UAGE" content="Visual Basic 7.0">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
Please Click on the DropDown List <br>
<asp:dropdownli st onclick="myfunc ()" id="DropDownLis t1" runat="server"
AutoPostBack="T rue">
<asp:ListItem Value="One">One </asp:ListItem>
<asp:ListItem Value="Two">Two </asp:ListItem>
<asp:ListItem Value="Three">T hree</asp:ListItem>
<asp:ListItem Value="Four">Fo ur</asp:ListItem>
</asp:dropdownlis t>

</form>
</body>
</HTML>

=============== ==
WebForm1.aspx.v b
=============== ==

Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents LinkButton1 As System.Web.UI.W ebControls.Link Button
protected WithEvents DropDownList1 as
System.Web.UI.W ebControls.Drop DownList

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Page.RegisterCl ientScriptBlock ("ClientScript" ,"<script
language=javasc ript>function myfunc(){alert( 'DropDown clicked. Now calling
server-side function');" + _
Page.GetPostBac kEventReference (DropDownList1) + "}</script>")

if Page.IsPostBack
Response.Write( "This is server side code. <br>")
End if
End Sub

Private Sub LinkButton1_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles LinkButton1.Cli ck
Response.Write( "This is server side code. You passed the value ["
& Request.Form("_ _EVENTARGUMENT" ) & "]<br>")

End Sub
Private Sub DropDownList1_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
DropDownList1.S electedIndexCha nged
Response.Write( "This is server side code. You passed the value [" &
Request.Form("_ _EVENTARGUMENT" ) & "]<br>")
End Sub

End Class

Please let me know if you have any questions regarding this.
Thanks,
Bassel Tabbara
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "paul reed" <pr****@jackson reed.com>
| Sender: "paul reed" <pr****@jackson reed.com>
| Subject: Wierd Behavior of __doPostBack
| Date: Mon, 7 Jul 2003 22:47:01 -0700
| Lines: 42
| Message-ID: <02************ *************** *@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcNFFFok0Du++Wn FQoWhuBqxOXLXqQ ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Path: cpmsftngxa09.ph x.gbl
| Xref: cpmsftngxa09.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:3291 4
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Hello,
|
| I am having some weird behavior between two machines...one
| which is running the 1.1 framework and one which is
| running 1.0. After opening a child form from a parent...I
| update the database then call the __doPostBack function of
| the window.opener. This has been working like a charm for
| the last several months. Our ISP where we run the .NET app
| recently upgraded to 1.1 of the framework. When I run my
| app at the ISP...the __doPostBack function in the
| window.opener dies with an "Undefined is not an object or
| is NULL" message on this line:
|
| theform.__EVENT TARGET.value = eventTarget.spl it("$").join
| (":");
|
| I have enclosed the entire __doPostBack function below.
|
| I DO NOT get this error when running on my development
| machine...anyon e have any ideas at all...I am at a loss.
| When I deploy I am compiling against the 1.0
| framework...so can't see how...even if the ISP is running
| 1.1 as well...that it would matter.
|
| Paul
|
| !--
| function __doPostBack(ev entTarget, eventArgument) {
| var theform;
| if (window.navigat or.appName.toLo werCase
| ().indexOf("net scape") > -1) {
| theform = document.forms["Form1"];
| }
| else {
| theform = document.Form1;
| }
| theform.__EVENT TARGET.value =
| eventTarget.spl it("$").join(": ");
| theform.__EVENT ARGUMENT.value =
| eventArgument;
| theform.submit( );
| }
|

Nov 17 '05 #2

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

Similar topics

6
1719
by: Qun Cao | last post by:
Hello, I am just starting to play threading in python, here is a really interesting problem I am very curious about: " import thread def main(): thread.start_new(test.()) def test():
0
1533
by: Frankieboy | last post by:
Where is __doPostBack-function defined? I've got an application which generates a different __doPostBack-function when the code is being run on the server compared to the one on my laptop. The version on server generates a script-error in the __doPostBack, while it runs without any problem on my developer-machine. The server is a Windows 2003 Server Standard Edition, while my developer machine is Windows XP Professional. Visual...
3
10888
by: E | last post by:
I have 2 aspx pages... neither of which do anything out of the ordinary. One of the pages automatically generates this block of code when viewed at the client: ------------------------------------------------------------ <form name="webfrmForm" method="post" action="pokedex.aspx" id="webfrmForm"> <input type="hidden" name="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" value="" /> <input type="hidden"...
1
2496
by: Adrian | last post by:
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.
3
2991
by: Marcelo | last post by:
Hello, I am trying to create a postback event, and it is working, just not calling the sub. I have a datagrid which has <asp:DataGrid id="Mensajes" ... <Columns> <asp:HyperLinkColumn ....
0
1182
by: Tom | last post by:
OK, here's a wierd one... I have a listbox, which I fill with strings (in my case, file names). I normally load this via a loop, adding each item to the list box in the loop. I put lb.BeginUpdate before the start of the loop, and lb.EndUpdate at the conclusion of the loop. Here's the wierd part: If there is only ONE line loaded into the list box, the list box SHOWS UP AS BLANK! It says there is 1 item in the box, but it never shows up on...
3
1551
by: Tom | last post by:
We are experiencing some wierd debugging behavior. What happens is that, during debugging with VS 2003, the debugger seems to 'skip' statements that are associated with database operations. For instance, I can be single-stepping through a VB.NET program, and once I hit a DB related statement (such as setting command parameters, executing a data reader, etc) the debugger will simply 'skip' ahead a number of statements (if not all the way to...
1
3084
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 invoke __doPostBack immediately after web page load. I have been attempting to use the HTML Body OnLoad event to trigger invoking __doPostBack without success. Any idea why __doPostBack can not be invoked at the HTML Body OnLoad event ? Do you...
4
1521
by: Muthu Arumugam | last post by:
Tried the following c# code static void Main(string args) { ArrayList list = new ArrayList(); int i = 10;
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.