Solved

ASP.NET doPostBack - Error : Expected ';' ?

Posted on 2004-03-21
7
2,047 Views
Last Modified: 2012-05-04
I have a form which is showing the error as Error : Expected ';' at  the javascript autogenerated by ASP.NET
here is the autogenerated code for your info
====================================
<form name="_ctl0:Default" method="post" action="MyForm.aspx" id="_ctl0_Default">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" value="dDw1MDcyNzUzNTY7dDw7bDxpPDI" />

<script language="javascript">
<!--
      function __doPostBack(eventTarget, eventArgument) {
            var theform;
            if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
                  theform = document.forms["_ctl0:Default"];
            }
            else {
                  theform = document._ctl0:Default;
            }
            theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
            theform.__EVENTARGUMENT.value = eventArgument;
            theform.submit();
      }
// -->
</script>
==============================

now the error is showing at the : (colon)
             else {
      theform = document._ctl0:Default;


Iam using Visual Studio 2003 with Framework 1.1,
OS : Windows 2003 Server Standard,
and IE 6

Why iam getting this error and how to rectify this.. Any help would get points immediately
0
Comment
Question by:pratap_surisoft
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:pratap_surisoft
ID: 10647186
Hi all, I just have 20 points to ask a question and i given the best, but this question worth 500 points i am sure
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10647249
i think that the problem can invoke by the name of the form
can you post the <form> tag

if the id of the form tag is Default it can cause such a problem
if i'm write change the id of the form tag with no usual value

B..G
0
 

Expert Comment

by:Dekkert
ID: 10647261
Hi, try removing all : characters. Also in your form name. Afaik javascript doesn't like colons.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:pratap_surisoft
ID: 10647532
That code was autogenerated by ASP.NET, nothing was done by me..  
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 10647569
yes,

but it's base on the
<form id="Default" method="post" runat="server"> which is again autogenerated from the vs in your html code of the .aspx

so you have to change the id from Default to something else because Default is reserved

B..G
0
 

Accepted Solution

by:
Rana_blr earned 20 total points
ID: 10647632
Hi, This is a problem with Framework 1.1,
just add the following code to ur codebehind and it will render the html and your error will go on the fly.
getback to me if it wont goes

using System.IO;
using System.Text;

protected override void Render(HtmlTextWriter writer) {
  StringBuilder stringBuilder = new StringBuilder();
  StringWriter stringWriter = new StringWriter(stringBuilder);
  HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
  base.Render(htmlWriter);
  string html = stringBuilder.ToString();

  int start = html.IndexOf("<form name=\"") + 12;
  int end = html.IndexOf("\"", start);
  string formID = html.Substring(start, end - start);
  string replace = formID.Replace(":", "_");
  html = html.Replace("document." + formID, "document." + replace);
  writer.Write(html);
}

0
 

Author Comment

by:pratap_surisoft
ID: 10647639
Hi All thanks again for your time spent on this question.
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question