Wierd Behavior of __doPostBack

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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();
    }
    paul reed Guest

  2. Similar Questions and Discussions

    1. Having a checkbox column and the grid disabled upon first load generated wierd behavior when Postback occurs.
      I have a grid with a checkbox column in it, that is disabled at Form_Load but it loaded with data anyway. Selecting a radio button enables it but...
    2. __doPostback method with colons problem
      I am running into the "colon in javascript" problem as discussed here http://www.bdragon.com/entries/000324.shtml. Basically, i have nested...
    3. __doPostBack EventArgument
      Hello, guys. I have this javascript to invoke serverside event that is attached to a hidden Button. ...
    4. Overriding __doPostBack
      I would like to change the name of the _doPostBack function emmitted by the ASP.NET framework to prefix it with an ordinal number i.e. the page...
    5. Wierd datalist behavior
      Hi, I have a datalist with some labels embedded inside. When the page loads, I can see all my labels contain text. on my...
  3. #2

    Default Re: Wierd Behavior of __doPostBack

    Teemu,

    Thank you so much for your input. My gosh MS certainly put egg on their
    face with this one.

    Regards,

    Paul



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Paul Reed Guest

  4. #3

    Default RE: Wierd Behavior of __doPostBack

    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
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    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
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    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" <prreed@jacksonreed.com>
    | Sender: "paul reed" <prreed@jacksonreed.com>
    | Subject: Wierd Behavior of __doPostBack
    | Date: Mon, 7 Jul 2003 22:47:01 -0700
    | Lines: 42
    | Message-ID: <02e301c34514$5a243290$a001280a@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();
    | }
    |

    Bassel Tabbara [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139