Solved

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

Posted on 2004-03-21
7
2,045 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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