The server tag is displaying an error due to incorrect formatting in the hyperlink data-binding section

I'm currently facing an issue with the formatting of my hyperlink. The text part of the hyperlink is working fine, which leads me to believe that the problem lies within the JavaScript. However, I am unable to pinpoint the exact issue.

<asp:TemplateField>
    <ItemTemplate>
        <asp:HyperLink ID="hypCustType" runat="server" 
            Text='<%# DataBinder.Eval(Container.DataItem, "CustType") %>'
            NavigateUrl="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, "CustType") %>');">
        </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

Answer №1

'There is an issue with the way you have closed the string in the NavigateUrl Property. In order to prevent the string from ending prematurely, you should use ' or \" inside of inline code. To correct this, you can try the following:

<asp:TemplateField>
    <ItemTemplate>
        <asp:HyperLink ID="hypCustType" runat="server" 
            Text='<%# DataBinder.Eval(Container.DataItem, "CustType") %>'
            NavigateUrl="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, \'CustType\') %>');">
        </asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>

Answer №2

Make the change from asp:hyperlink to a standard HTML link:

<a href="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, "CustType") %>');">
            <%# DataBinder.Eval(Container.DataItem, "CustType") %>'</a>

Answer №3

Here is a suggestion:

<asp:LinkButton ID="linkCustomerType" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustomerType") %>' OnClientClick='<%# "javascript:sendValue(\"" + DataBinder.Eval(Container.DataItem, "CustomerType") + "\");" %>'></asp:LinkButton>

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

Updating the Background Color of a Selected Checkbox in HTML

I have a straightforward question that I've been struggling to find a simple answer for. Can anyone help me with this? Here's the checkbox code I'm working with: <input type="checkbox"> All I want to do is change the backgr ...

Inject a value sent from response.render directly into the script tag

Below you will find a pug snippet. I am looking for a way to dynamically insert the user value into the chatConfig object. script. var chatConfig = { user : 'foo', pass : 'bar', } When rendering from my Express applicatio ...

Troubleshooting Subtle Validation (on the front end)

After implementing unobtrusive validation, I noticed that my form appears error-free upon initial inspection. However, when I execute the following code: $(valForm).valid(); The result returned is false. To troubleshoot this issue, I want to determine ...

Unusual behavior: Django app not triggering Ajax XHR onload function

I'm currently working on a Django app that features user posts, and I'm in the process of implementing a 'like' / voting system. Initially, I set up this functionality using complete page refreshes combined with a redirect after the vot ...

Enhancing Bootstrap Slider Range with jQuery/Javascript

Currently, I have incorporated the Bootstrap slider into a webpage that features two sliders on a single page. The range of the second slider depends on the value of the first one. It is crucial for me to be able to update the range of the second slider af ...

The declaration of 'exports' is not recognized within the ES module scope

I started a new nest js project using the command below. nest new project-name Then, I tried to import the following module from nuxt3: import { ViteBuildContext, ViteOptions, bundle } from '@nuxt/vite-builder-edge'; However, I encountered th ...

How can JavaScript determine if this is a legitimate JS class?

I'm currently in the process of converting a React.js project to a next.js project. In my project, there's a file named udf-compatible-datafeed.js. import * as tslib_1 from "tslib"; import { UDFCompatibleDatafeedBase } from "./udf-compatibl ...

Steps to decode a data URL into an image and render it on a canvas

With 3 canvases at my disposal, I decided to get creative. First, I cropped a region from canvas1 and showcased it on canvas2. Then, I challenged myself to convert the image in canvas2 into a URL and then reverse the process back to an image, all to be d ...

In main.js within the Google Maps API, an error is triggered when trying to setDraggable(false) on a

Here's a piece of JavaScript code I'm working with: google.maps.event.addListener(mark, 'dragend',x(mark)); function x(mark) { mark.setDraggable(false); } Recently, when I try to move a marker to a different position, I encounter ...

Experiencing the Pause: A Fresh Take on

I'm currently using this slideshow for a project, and I need to understand if it's possible to resume its interval. The current issue is that when you hover over the slideshow, the progress bar stops. But once you remove the mouse, it continues f ...

Is there a way to set up a listener for a particular property of a recoil state object?

Is it possible to create a listener for a specific property within a state object? Let's look at an example: type ExampleAtomProperties = { id: number; description: string; }; const ExampleAtom = atom< ExampleAtomProperties>({ key: &quo ...

Ways to eliminate a particular element from the React state

I need help removing a specific item from my React state. Current scenario: When certain checkboxes are selected, I update their state accordingly. My useEffect hook has the checkboxes state as its dependency, and every time there is a change, I add cont ...

Best practices for utilizing child component methods within a parent component in VUE

I am working with the ImageUpload.vue component, which is a straightforward Bootstrap modal containing a few methods. I am currently exploring the best approach to utilize one of these methods. Could it be implemented like this: const app = new Vue({ ...

Building a visual progress tracker in Visual Basic .NET

I have been on the hunt for a while now trying to find a tutorial or any resources, but so far my search has been in vain. What I'm trying to achieve in my web application is to create a progress bar that resembles the one found in window form control ...

Tips for navigating the world of hybrid web applications that combine elements of both traditional multi-page applications and single-page

What are some best practices for developing a multi-page application using modern JavaScript frameworks? Multi-page Application In a multi-page application, we utilize multiple templates with "template syntax" to retrieve backend data and handle AJAX (if ...

Update Table Row Background Color in Separate Table by Clicking Button Using JQuery

Two tables are involved in this scenario - one that receives dynamically added rows, and another that stores the data to be included. The illustration above displays these tables. Upon clicking the Edit button, the information from the selected row in Tab ...

Discovering which chip has wrapped to the next line in Material UI Autocomplete can be found by closely inspect

Currently, I am working with a Material UI autocomplete feature that functions as follows: https://i.sstatic.net/4LrwI.png My goal is to determine when the fourth chip wraps to the next line within the autocomplete so that I can proceed with additional c ...

A method for increasing a counter using only an instance of a class or function without accessing its methods or properties in Javascript

Looking at the task ahead, let increment = new Increment(); I have been tasked with creating a Javascript class or function called Increment in order to achieve the following: console.log(`${increment}`) // should output 1 console.log(`${increment}`); ...

Is it possible to dynamically change a form's input value using a JavaScript keyup function based on input from other form elements?

My form utilizes the keyup function to calculate the total value of 3 input fields by multiplying them and displaying the result. Below is a fiddle showcasing this functionality: $(document).ready(function () { $(".txtMult1 input").keyup(multInp ...

Parse through a JSON input and generate a hierarchical treeview structure using the specified keys, while also considering any child keys present

Can someone assist me with the code snippet below? JObject my_obj = JsonConvert.DeserializeObject<JObject>(ReceivedJson); ParseJson(my_obj); //method to store all the nested "keys" and the "id" values public void ParseJson(JObject obj) ...