Solved

Why am I getting an "Unexpected token" error on the HTML generated from my AjaxToolkit:NumericUpDownExtender on my ASPX page in IE11

Posted on 2014-09-02
5
1,225 Views
Last Modified: 2014-09-07
Hi:

I've got an ASP.Net webpage which uses the AjaxToolkit NumericUpDownExtender.

I've been testing/debugging using Chrome and IE 11.
In IE11, I am getting some errors on the generated HTML on the page. Everything looks OK in Chrome.
I'm not sure if this an issue or not, but I would like to understand what is going on and how to correct it.

The HTML on the original ASPX page looks like this:
<ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="txtQuantityOfCases"
  Minimum="1" Width="120" TargetButtonDownID="imgDown" TargetButtonUpID="imgUp" ClientIDMode="Static" />
<asp:TextBox ID="txtQuantityOfCases" runat="server" Style="text-align: center" Text="1" Width="20px" ClientIdMode="Static"/>
<table id="Table1">
  <tr>
     <asp:ImageButton ID="imgUp" runat="server" ImageUrl="~/images/NumericUpDown/up.gif" 
       AlternateText="Down" Width="7px" Height="7px" BorderStyle="None" />
  </tr>
  <tr>
     <asp:ImageButton ID="imgDown" runat="server" ImageUrl="~/images/NumericUpDown/down.gif"
       AlternateText="Up" Width="7px" Height="7px" BorderStyle="None" />
  </tr>
</table>

Open in new window

In Chrome, the HTML on the rendered page looks like this:
<input name="ctl00$MainContent$txtQuantityOfCases" type="text" value="1" id="txtQuantityOfCases" style="width:20px;text-align: center">
<input type="image" name="ctl00$MainContent$imgUp" id="MainContent_imgUp" src="../images/NumericUpDown/up.gif" alt="Down" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$imgUp&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="border-style:None;height:7px;width:7px;">
<input type="image" name="ctl00$MainContent$imgDown" id="MainContent_imgDown" src="../images/NumericUpDown/down.gif" alt="Up" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$imgDown&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="border-style:None;height:7px;width:7px;">

Open in new window


It appears to work fine with no errors
In IE11, the HTML on the rendered page looks this:[
<input name="ctl00$MainContent$txtQuantityOfCases" type="text" value="1" id="txtQuantityOfCases" style="width:20px;text-align: center" />
<table id="Table1">
  <tr>
    <input type="image" name="ctl00$MainContent$imgUp" id="MainContent_imgUp" src="../images/NumericUpDown/up.gif" alt="Down" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$imgUp&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="border-style:None;height:7px;width:7px;" />
  </tr>
  <tr>
    <input type="image" name="ctl00$MainContent$imgDown" id="MainContent_imgDown" src="../images/NumericUpDown/down.gif" alt="Up" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$imgDown&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" style="border-style:None;height:7px;width:7px;" />
  </tr>
</table>

Open in new window


It displays the following errors in the IE debugging tool:
HTML1506: Unexpected token.
File: MakePTILabelWithSerialNumber.aspx, Line: 312, Column: 69
HTML1506: Unexpected token.
File: MakePTILabelWithSerialNumber.aspx, Line: 315, Column: 69

Open in new window

Where lines 312 and 315 line up with the generated HTML input control.

Can someone help shed some light on this?

Thanks,
JohnB
0
Comment
Question by:jxbma
  • 3
  • 2
5 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40300753
replace &quot; by '
0
 
LVL 1

Author Comment

by:jxbma
ID: 40301461
Remember the generated HTML is what is causing the error.
That HTML is generated once the ASPX page is compiled into HTML.
I don't (or at least I don't know of a way to) have control over what the generated HTML looks like.

JB
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40301513
so maybe you can put a function in a script tag.

<script type="text/javascript" language="javascript">
function doThat(el) {
      var nw = new WebForm_PostBackOptions(el.getAttribute("name"), "", true, "", "", !0, !0);
      WebForm_DoPostBackWithOptions(nw);
}
</script>

Open in new window


and use :
onclick="doThat(this)"
0
 
LVL 1

Author Comment

by:jxbma
ID: 40301726
leakim971:


Thanks for the response. Yes, I believe that would work.

For me I guess I'm confused/concerned as to why code generated by the AjaxToolkit (Microsoft) doesn't work as is out of the box in a browser written by (Microsoft).

JB
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40301745
lol, I think MS itself don't know, too much people in the box...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 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