Reloading a page upon a client's click in ASP.NET webpage

<asp:Button ID="btnExpand" runat="server" CssClass="btn" Text="Expand" ToolTip="Expand text area to view all text"
            Enabled="true" OnClientClick="return false;"/>
<asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" ToolTip="Shrink text area to original size"
            Enabled="false" />
<script type="text/javascript">                     
    document.getElementById('<%= this.btnExpand.ClientID %>').addEventListener("click", function () {
        if (document.getElementById('<%= this.txtTextArea.ClientID %>').clientHeight < document.getElementById('<%= this.txtTextArea.ClientID %>').scrollHeight) {
            document.getElementById('<%= this.txtTextArea.ClientID %>').style.height = document.getElementById('<%= this.txtTextArea.ClientID %>').scrollHeight+ "px";
            document.getElementById('<%= this.btnShrink.ClientID %>').disabled = false;
            document.getElementById('<%= this.btnExpand.ClientID %>').disabled = true; 
        }
        return false;
    });
    document.getElementById('<%= this.btnShrink.ClientID %>').addEventListener("click", function () {
        document.getElementById('<%= this.txtTextArea.ClientID %>').style.height = '80px';
        document.getElementById('<%= this.btnShrink.ClientID %>').disabled = true;
        document.getElementById('<%= this.btnExpand.ClientID %>').disabled = false;
        return false;
    });

page is reloading when shrinking in IE, but works fine in Chrome

Answer №1

Maybe you should consider making the following adjustment:

 <asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" 
 ToolTip="Shrink text area to original size" Enabled="false" OnClientClick="return false;" />

Instead of:

 <asp:Button ID="btnShrink" runat="server" CssClass="btn" Text="Shrink" 
ToolTip="Shrink text area to original size" Enabled="false" 
OnClientClick="return false;" />

EDIT:

You may want to update your code to this:

<input type="button" runat="server" class="btn" title="Shrink text area to original size" onclick="return false;"/>

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

There may be issues with evaluating the expression due to code optimization or a native frame being at the top of the call stack

Currently, I am in the process of developing a website that allows users to submit information. Once the information has been submitted, I am attempting to simultaneously send two emails - one to my sales team and one to the visitor on the site. However, ...

Obtain the server name in ASP.Net running on the Internet Information Services (

After posting my question here I am trying to retrieve the hostname in the Application_Start method using the code snippet below: if(string.IsNullOrWhiteSpace(Hostname)) Hostname = Dns.GetHostName(); However, I am encountering an issue where it ...

Refreshing a component in React when a prop changes

My understanding is that React components update when their props or state change. For example, I declare a variable like this: let percentage = { width: '10%', }; Then, I have a function using setInterval to upd ...

Injecting JavaScript page level variable into an integrated Angular2 RC 1 application

To keep this brief, the issue I'm facing is an extension of a Stack Overflow question regarding passing page-level variables into an Angular 2 app service. Following Gunter's advice from the provided SO question, I attempted to pass a JavaScript ...

Database-Driven Ajax Information Display

https://i.sstatic.net/GE8RI.pngI retrieved some data from the database and successfully displayed it after an ajax call. However, one of the variables contains array data that was saved using the implode function. The data looks like (a,b,c,d). The curren ...

Ensure that each of the two divs maintains a 16:9 aspect ratio, and utilize one div to fill any remaining empty space through the

This layout is what I am aiming for: https://i.sstatic.net/uZdty.png While I can achieve a fixed aspect ratio with a 16:9 image by setting the img width to 100%, I run into an issue where the height scaling of flexbox becomes non-responsive. The height re ...

I am encountering problems with images that are imported as module imports in a Vue.js project

Currently, I have stored all the default images for my Vue project in a designated folder. The path to this folder is web/images/defaults/<imageNames>.png. Instead of importing each image individually in my components, I wish to create a file that co ...

Enhancing Angular with Plotly: Implementing click events on bar chart legends

I'm currently working on implementing color pickers for my plotly-plot charts within an Angular template. I am looking to add a function that triggers when the chart legend is clicked. How can I achieve this and get a click event for the chart legends ...

Retrieve the most recent CSS or JavaScript code following a dynamic loading process

During my web page development, I frequently utilized the time() function for dynamic refresh. <link rel="stylesheet" href="/theme.css<?php echo '?'.time(); ?>"> Now that my code (style sheet) is more stable, I am interested in cach ...

What is the HTML header used for returning in requests?

Currently, I am facing a challenge similar to what was discussed in this thread and this one. My goal is to track a sub-session for users based on their browser tabs. However, my specific focus is on figuring out a method to attach a request parameter to e ...

Navigating through URLs and displaying HTML pages using NodeJS

I am currently learning Node.js programming and encountering a small issue. Whenever I try to access localhost:3000/, I want the homeController to execute the index function and display the HTML file. APP.JS const express = require('express') c ...

Making an ajax request to an ASP.NET MVC controller

Hello there! I am currently working on implementing AJAX functionality to call my controller when the "remove' button is clicked. Although the image preview gets removed, unfortunately, my controller breakpoints are never being hit. If someone could t ...

Obtaining an OBJECT from a hashmap instead of a string

In my code, I am working with a hashmap and I want to extract all the values from this map without needing to reference a specific key. Here is a basic overview of the process: Create a hashmap using an external file with a structure of "id:value" Utili ...

What is the best way to validate a form using JavaScript?

Recently, I completed a chess-themed hobby project using HTML, CSS, and PHP. The project allows users to view and list possible moves for a chess piece based on its type, color, and location on the board. However, the program does not take into account the ...

`The header navigation is not responding to window resizing functionality`

I am currently developing a header navigation that consists of a logo on the left side, a profile icon on the right side, and some navigation links in the middle. A left slide menu has been implemented to trigger when the window width is less than 700px. ...

The expiration and creation of access tokens in the Gmail API

For the past 6 months, I have been utilizing the Google API to send emails from my server in a Node.js project. I have successfully set up credentials and generated both refresh and access tokens, which I have been using consistently. oAuth2Client = new go ...

React.js implementation of individual checkboxes for every row in a table

My functional component contains a table with multiple rows as shown below: import React from "react"; import Checkbox from "@material-ui/core/Checkbox"; function Table({ data }) { const [checked, setChecked] = useState(false); ...

What will occur when running a web application with a radsplitter implemented in the master page?

Incorporated the RadSplitter into my masterpage and structured my webform using the same masterpage. Encountering an issue with this component where the contentplaceholder in my webform is merging with the footer of the page at runtime, preventing me from ...

Should you venture into MVC for your next project, or remain loyal to WebForms?

As a front-end developer, I have gained experience in ASP.NET WebForms while working on multiple projects at my agency. Currently, I am considering using MVC for a new project, however, the developer I have in mind believes that MVC is not necessary. He a ...

Transferring JSON data using DWR (Direct Web Remoting)

Utilizing DWR for AJAX calls in my project involves the conversion of JavaScript objects to Java objects by analyzing the Java class. My goal is to send and receive a JSON-like structure through DWR. For example: JavaScript Object: { "name" : "TamilVe ...