Modify the style attribute of a LinkButton using JavaScript

I am trying to modify the style attribute of a LinkButton using javascript. I have successfully managed to do this for a DropDownList, but not for the LinkButton.

Below is my code snippet:

            </asp:ListItem>
            <asp:ListItem Text="vikas" Value="0">

            </asp:ListItem>
        </asp:DropDownList>
        <asp:LinkButton ID="lnkbtnSave" Style="display: none" Text="Save" runat="server"></asp:LinkButton>
        <asp:LinkButton ID="lnkbtnCancel" Style="display: none" Text="Cancel" runat="server"></asp:LinkButton>
        <asp:TextBox ID="lnkbtnTest" Style="display: none" Text="hope" runat="server"></asp:TextBox>
        <asp:LinkButton ID="lnkbtnChangeHR" Text="Change Hiring Manager:" runat="server"
            OnClientClick="javascript:return Toggle(this.id);"></asp:LinkButton>
    </div>
    <script type="text/javascript" language="javascript">
        alert('heart, please be careful');

        function Toggle(id) {
            alert(document.getElementById(id.replace("lnkbtnChnageHR", "lnkbtnTest")));
            document.getElementById(id.replace("lnkbtnChangeHR", "ddlHiringManager")).style.display = 'inline';
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnSave")).style.display = 'inline';
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnCancel")).style.display = 'inline';
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnChangeHR")).style.display = 'none';
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnSave")).style.color = "#f6f6f6";
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnCancel")).style.color = "#f6f6f6";
            document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnTest")).style.display = 'inline';
            alert(document.getElementById(id.replace("lnkbtnChangeHR", "lnkbtnCancel")).style.display == 'none');
            return false;
        }
    </script>

Answer №1

Apologies, everyone, it turned out to be the PICNIC

The culprit was actually lnkbtnChangeHR, not lnkbtnChnageHR

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

The JavaScript function is not executing the Node.js code as expected

Currently, I am utilizing Twilio to send a sample message when running the provided code in the terminal: var accountSid = '...'; var authToken = '...'; var twilio = require('twilio'); var client = new twilio(acco ...

Tips for enhancing the functionality of components within Vue

My expertise lies primarily in React, and I'm now exploring the Vue-centric approach to achieve the following: I want to enhance this component: , so that the label-position is set to top on mobile devices and left on desktop. However, I'm not s ...

Using setInterval() in codeigniter does not function as expected

The setInterval() function is functioning properly in corePHP, but it does not seem to work in CodeIgniter. I am trying to retrieve data from another controller without having to reload the page. CONTROLLERS home.php <?php defined('BASEPATH&apos ...

What is the best way to create a dynamic icon using React and TypeScript?

Excuse me, I am new to using React and TypeScript. I'm having trouble getting the icon to change based on the status in AppointmentType. The body color is working fine, but the icons are not changing. Can someone please help me solve this issue? const ...

Do I really need to run npm install for each new React project I start?

Currently, as I delve into learning React, I have accumulated 30 projects each with setup and final versions. However, I've noticed that each installation is taking up between 150 - 200 mb without any particularly heavy dependencies. Is there a way to ...

Place the divs over the background image by using relative positioning

I am working on a project where I have a full-width div with a background image containing people. I want to display a tooltip when hovering over each person, but I am facing challenges in aligning the divs properly. Image maps with % widths do not seem t ...

Is there a quick method to "install or fetch" for NodeJS?

I'm currently working on a piece of code that has the ability to proactively address missing dependencies without any need for manual intervention. What I envision is something along the lines of var aes256 = require_or_install('nodejs-aes256&ap ...

Getting an input value dynamically in a React variable when there is a change in the input field

I am having an issue with my search text box. I need to extract the value onchange and send a request to an API, but when I try using the normal event.target method, it shows an error. How can I fix this? The problem is that onchange, I need to call a func ...

Angular and dropdowns: a perfect match

Imagine having a controller like this: myApp.controller('testCtrl', function ($scope) { $scope.cars = [ { carId: '1', carModel: 'BMW', carOwner: 'Nader' }, { carId: '2', carModel: &apos ...

"Enhancing User Experience with Stylish Drop-down Menu Hover

I'm working on a CSS drop-down menu that has a hover effect, but I'm facing an issue where the a element within the li is not taking up the full width of the li. I want it to utilize the entire width of the li, especially on hover. Does anyone ha ...

Seamless Shift: Effortless Transition

I'm attempting to develop a unique hover effect for a button. Initially, the button only displays an outline and its name inside. However, upon hovering over the button, I want it to smoothly transition to my gradient background. Despite trying multip ...

Is there a way to position a video towards the right side of the screen?

I'm working with an HTML5 video that has a height greater than its width. I've set the video to have 100% in height and 100% in width so it scales automatically based on my window size. However, I want the video to be positioned on the right sid ...

How to Execute a Class Function from a Different File in React by Clicking a Button in

I have integrated a chart on my website with an interactive feature that allows an object to be displayed by pressing a key in the chart.js file. I now want to replicate this functionality using a button click instead. chart.js ... onKeyPress(e) { c ...

Tips for creating a see-through scrollbar in React?

Lately, I've been experimenting with adding overflow-Y: scroll to materialize collections in order to maintain a fixed wrapper height. However, my latest challenge has been figuring out how to make the scrollbars transparent. I've come across sug ...

Executing server-side operations after a request has been sent

Recently, I discovered that entering the following URL into my browser results in a .csv file being downloaded to my Downloads folder on My Computer. The word YHOO represents the stock symbol for Yahoo: Is there a way for me to replicate this process on m ...

Eliminate the empty gap preceding the slideshow

I have a slideshow and aside content in HTML. My goal is to eliminate the space below the slideshow so that the aside content can be positioned right next to the end of the slideshow. Unfortunately, I am unsure how to remove this space without disrupting ...

How can I create an HTML custom upload button that changes to a hand cursor when hovered

Utilizing the CSS style tip shared in this post, I successfully designed a custom upload button. However, the new challenge is to ensure that the entire button area changes the mouse pointer icon to a hand. You can view my partial solution here (jSFiddle) ...

Can the CSS styles of a webpage be modified post-page load?

Hello there! I've been working on implementing a "dark mode/light mode" feature for my website. My approach involves using two different CSS style sheets and toggling between them using a single button So far, I've experimented with various meth ...

Managing the checkboxlist status within a gridview in asp.net

I am facing an issue with a checkboxlist in one of the columns of my gridview. The checkboxlist has 4 listitems and is not populated from the database. My goal is to preserve the state of all the listitems (checked or unchecked) when navigating to another ...

What is the best way to use console.log for passing parameters in an AJAX request?

Is there a way to properly utilize console log in this scenario? $.post("greeting", { salutation: console.log(5 + 6), name: "Friend" }, I am facing issues when trying to pass the result to the ajax param salutation. Any suggestions on how to resolve this ...