Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 551
  • Last Modified:

Javacript __doPostBack can not find

I have an web appliction using ASP C#.  In my aspx file  I have a javascript which looks like this

<script language="javascript">
            
            function rowchanged()
            {
             alert("I am here rowchanged javascript");
             __doPostBack('RowChanged','');
            }
            
</script>

In my aspx.cs file I have a function RowChanged

When I run the application, I always always get an error saying  __doPostBact object doesn't exist.

When I include a  script like the following
<script language="javascript">
            <!--
             function __doPostBack(eventTarget, eventArgument)
             {     
                      var theform = document.Form1;
                          theform.__EVENTTARGET.value = eventTarget;
                          theform.__EVENTARGUMENT.value = eventArgument;
                          theform.submit();
           }
          -->
      </script>
            

it gets to the function, but has trouble with theform object.

I thought the _doPostBack function is an included function.  I know I never had to include with other apps.   I don't know what to do.  I have spent days on this.  Please HElp Please.
0
kathywargo
Asked:
kathywargo
  • 3
  • 2
1 Solution
 
mrichmonCommented:
The doPostback function should be created automatically by .NET - you should not be including one.

Are you using .NET 1.1?  If so did you remove the bottom portion of the code behind file that is autogenerated?
0
 
kathywargoAuthor Commented:
I am sorry.  I am using .Net 1.1 but I am not sure of what you mean about the bottom portion of the code.  Could you explain a bit more
0
 
smaccariCommented:
Maybe you should just make sure you actually have a form Form1 in your aspx page.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mrichmonCommented:
There will be a section (or should be) at the bottom of the code behind page that looks like this:

#region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.Load += new System.EventHandler(this.Page_Load);
            }
            #endregion


If it is missing then often the page does not function with certina things like the __dopostback
0
 
kathywargoAuthor Commented:
Okay.

Ichecked both of these ideas.  The code is okay .  I have the OnInit and its associated functions.

When I use the debugger it does say object cannot be found and it show Jscript functions.  Is there something in the project properties.  Could some one provide a small example in c# that I could build from  
0
 
mrichmonCommented:
A small example of a generic web page?  Of something else?

Web form:

aspx page:
------------------------
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="LS.Web.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.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <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">

     </form>
      
  </body>
</html>

aspx.cs page
-----------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace MyWeb
{
      /// <summary>
      /// Summary description for WebForm1.
      /// </summary>
      public class WebForm1 : System.Web.UI.Page
      {
            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here
            }

            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.Load += new System.EventHandler(this.Page_Load);
            }
            #endregion
      }
}
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now