Solved

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

Posted on 2004-03-21
7
2,038 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now