Solved

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

Posted on 2004-03-21
7
2,035 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

760 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