473,406 Members | 2,954 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,406 software developers and data experts.

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.__EVENTTARGET.value = eventTarget.split("$").join
(":");

I have enclosed the entire __doPostBack function below.

I DO NOT get this error when running on my development
machine...anyone 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(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase
().indexOf("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value =
eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value =
eventArgument;
theform.submit();
}
Nov 17 '05 #1
1 6788
Hello Paul,
The way you are implementing the postback is highly not recommended.

This is accomplished by using two methods:
- RegisterClientScriptBlock
- GetPostBackEventReference

RegisterClientScriptBlock 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
RegisterClientScriptBlock
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemWebUIPageClassRegisterClientScriptBlock Topic.asp
GetPostBackEventReference 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
GetPostBackEventReference
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwebuipageclassgetpostbackeventreference topic.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="WebForm1.aspx.vb" Inherits="CustomerDemosVB.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
Please Click on the DropDown List <br>
<asp:dropdownlist onclick="myfunc()" id="DropDownList1" runat="server"
AutoPostBack="True">
<asp:ListItem Value="One">One</asp:ListItem>
<asp:ListItem Value="Two">Two</asp:ListItem>
<asp:ListItem Value="Three">Three</asp:ListItem>
<asp:ListItem Value="Four">Four</asp:ListItem>
</asp:dropdownlist>

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

=================
WebForm1.aspx.vb
=================

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
protected WithEvents DropDownList1 as
System.Web.UI.WebControls.DropDownList

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

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

#End Region

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

Page.RegisterClientScriptBlock("ClientScript","<sc ript
language=javascript>function myfunc(){alert('DropDown clicked. Now calling
server-side function');" + _
Page.GetPostBackEventReference(DropDownList1) + "}</script>")

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

Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click
Response.Write("This is server side code. You passed the value ["
& Request.Form("__EVENTARGUMENT") & "]<br>")

End Sub
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
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****@jacksonreed.com>
| Sender: "paul reed" <pr****@jacksonreed.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++WnFQoWhuBqxOXLXqQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: cpmsftngxa09.phx.gbl
| Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.aspnet:32914
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.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.__EVENTTARGET.value = eventTarget.split("$").join
| (":");
|
| I have enclosed the entire __doPostBack function below.
|
| I DO NOT get this error when running on my development
| machine...anyone 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(eventTarget, eventArgument) {
| var theform;
| if (window.navigator.appName.toLowerCase
| ().indexOf("netscape") > -1) {
| theform = document.forms["Form1"];
| }
| else {
| theform = document.Form1;
| }
| theform.__EVENTTARGET.value =
| eventTarget.split("$").join(":");
| theform.__EVENTARGUMENT.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
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
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...
3
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:...
1
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...
3
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
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...
3
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...
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...
4
by: Muthu Arumugam | last post by:
Tried the following c# code static void Main(string args) { ArrayList list = new ArrayList(); int i = 10;
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.