Tips for managing JavaScript errors

<ItemTemplate>
    <tr class="row">
        <td style="width: 88%;">
            <input id="hdnPackageProuctId" type="hidden" value='<%# Eval("ID")%>'  />
            <div style="float:left; margin-top:5px;height:18px;">
                 <input type="radio" id="ChkIsProduct" name="chkProductsList" onclick="hdnSelectedProdName.value='<%# HttpUtility.JavaScriptStringEncode(Eval("Name"))%>'; hdnSelectedProdID.value='<%# Eval("ID")%>';"     />&nbsp; 
            </div>
            <div style="float:left;font-size:12px;margin-top:5px; font-weight:bold; width:300px;height:18px;"  class="gvColSet tLightBlack gvtruncate" title='<%# Eval("Name")%>'>  
                <%# Eval("Name")%>  
            </div>
        </td>
        <td align="right" style="width: 12%;">
           <div id="dvPrice" class="gvColSet tLightBlack gvColAlignLeft" style="font-size:12px; float:left; width:95px;  "><%# FormatNumber(Eval("SalePrice"), 2)%></div>`enter code here`
           <input id="hdnUnitPrice" type="hidden" value='<%# FormatNumber(Eval("SalePrice"), 2)%>' />
        </td>
   </tr>
</ItemTemplate>

This specific section functions as the item template for a repeater. However, I am encountering a Javascript error when clicking on the checkbox:

onclick="hdnSelectedProdName.value = '<%# HttpUtility.JavaScriptStringEncode(Eval("Name"))%>';
hdnSelectedProdID.value='<%# Eval("ID")%>';

I have attempted to troubleshoot the issue but have been unsuccessful in identifying the root cause.

Answer №1

must have

onclick="setSelectedName('<%# HttpUtility.JavaScriptStringEncode(Eval(\"Name\"))%>');
setSelectedID('Eval(\"ID\")');

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way for me to retrieve the text response of a fetch request from client-side JavaScript to fastify server?

In my fastify node.js application, I am encountering an issue where I can see the text results of a promise right before it is returned to the browser's JavaScript code. However, once the promise is returned to the browser JS, all I get is an empty st ...

What's the process for converting offsetX and offsetY pixel coordinates to percentages?

Currently, I am working on a project where I need the offsetX and offsetY coordinates to be displayed in percentage (%) format while hovering over a div element. By default, these coordinates are shown in pixels. Here is an example of the structure: < ...

How would you utilize jQuery to access the "option" array of a select control with the attribute of multiple=true by utilizing the find() method?

When using jquery, I am attempting to access selected items from a select control that has multiple=true. My goal is to reference them by name criteria and then iterate through the list. Below is my current code snippet: var currentRow = $(this); // sele ...

Retrieving data from multiple mongo collections and merging selected attributes from the output

I'm attempting to query a Mongo collection, extract an attribute from each object returned, use that attribute to retrieve data from another collection, and then combine the data. I am unsure of how to achieve this on mongoDB. To break it down, what I ...

Technique for Providing a User with a Compilation of Suggestions

After setting up the database and tables, as well as model classes with corresponding properties, I am now looking to create a method in the controller class [Asp.Net MVC] that will generate a list of music recommendations for users. These recommendations ...

Add different input strings to an array within the scope when there is a change in the input value (AngularJS)

My goal is to populate an empty array within the scope with strings. The number of elements in this array can vary depending on what the user types in the player count input field. $scope.playerNames = []; To achieve this, I am using a $watch function th ...

Creating a text design that spans two lines using Scalable Vector Graphics (SVG

I am working with an SVG that displays strings pulled from an Array... {"label":"Here is an example of the string...", "value":4}, The text above is shown in an SVG element as... <text>Here is an example of the string...<text> I would like ...

Steps to eliminate a choice from the MUI Datagrid Column Show/Hide feature

I am attempting to customize which columns are displayed on the <GridToolbarColumnsButton/> component within the MUI Datagrid toolbar (refer to the image below) https://i.stack.imgur.com/joZUg.jpg Potential solution: I have been exploring the AP ...

Use a combination of the reduce and map functions in JavaScript to transform a one-dimensional array into a multi-dimensional array

Below is an array containing mySQL results: [ {"eventId":"84","shootId":"72","clubEventId":"253","clubId":"7"}, {"eventId":"84","sh ...

When using the require() function in Node.js, the period "." is not being recognized as part of the command and

I recently encountered a problem while working on my project and reorganizing my files. I noticed that the "." in my requires are not being parsed correctly. Upon running my program, an error message is displayed: Error: Module './src/map/createMa ...

JavaScript conditional statement malfunctioning

I am currently facing an issue with my JavaScript script. I am using jQuery to send data via AJAX to a PHP file and expecting a text dataType in return so that I can test it with JavaScript. My objective is to redirect the user to another webpage if the t ...

Retrieve pixel information upon touch in an Appcelerator Titanium application on Android or iPhone

Can pixel level data of an image view be accessed using Titanium Mobile on Android/iPhone? ...

The absence of a semicolon in the non-null assertion is causing an

Within my code, I have a function that arranges a set of cards according to a specific coordinate system: const orderCardsInPage = (items: OrderItemType[], pageCards: CardType[]) => { return pageCards.sort((firstCard, secondCard) => { con ...

Creating dynamic links within HTML through real-time updating

In my application, I have a feature that generates a list of words and converts them into clickable links. When the user clicks on a link, I want to extract the {{word.name}} from the HTML link without navigating to a new page. I simply need to retrieve th ...

Is it possible to include if else logic code within a catch statement?

There's a nagging feeling within me that having logic code within a catch statement is not the right approach. For example, my catch block currently looks like this: try{ // do some stuff that throws some unexpected errors } ...

Unusual Glitch in Bootstrap 3 Dropdown Menu

I am currently developing a website using Bootstrap 3. I am encountering an issue with the navbar dropdown. When I click on the link, it changes to show "expand child menu" and "collapse child menu". To clarify, here is the image I am referring to: Initi ...

What is the best way to include a JavaScript variable within CSS styling?

I am currently implementing a dropdown menu system where the image of a parent div changes on mouse hover over a link, and reverts back when the mouse moves away. I have this functionality set up using a variable in my HTML code. Is there a way for me to m ...

Unsure of the best way to approach pagination using {$.getJSON, php image array} - seeking guidance on the right

Currently, my code is set up as follows: When a user visits a specific link on the page The $.getJSON function sends a request to a PHP script PHP uses scandir() to generate an array containing image names (eventually in the hundreds to thousands, ...

Vuejs method to showcase input fields based on form names

I am working on a Vue.js form component with multiple input fields, but now I need to split it into two separate forms that will collect different user input. Form 1 includes: Name Surname Email with a form name attribute value of form_1 Form 2 i ...

Retrieving specific value from a Parent Controller in AngularJS using UI Router

I have a request to display the value stored in $scope.resAVal on my index.html page. This value is accessible within the RootCtrl. index.html <!DOCTYPE html> <html ng-app="plunker"> <head> <!-- any required JavaScript librarie ...