The text on the asp:Button displays incorrectly in IE8+

The content inside the button slightly shifts or moves downward by a few pixels.

<div>
<asp:Button runat="server" ID="Button1" CssClass="ButtonClass" Text="" runat="server" />
</div>

ascx.cs:

Button1.Text = LocalizationResourceManager.GetLocalizedValue("Button_Text");

CSS:

.ButtonClass{
 background: url('/Button.png') no-repeat scroll 0 0 transparent;
 cursor: pointer;
 font-weight: bold;
 font-size: 14px;
 height: 33px;
 padding-bottom: 7px;
 padding-right: 19px;
 width: 180px;
 border: solid 0px;
 color: #fff!important;
 background-position: 0px -31px;
}

If I could use a <span>, this could have been resolved with:

{position:relative;top;0;left:0;}

As span cannot be utilized within an asp:button, I need to find a solution for this button itself.

I attempted:

<asp:LinkButton ID="Button1" runat="server" CssClass="ButtonClass">
    <span runat="server" id="ButtonText"></span>
</asp:LinkButton>

ascx.cs:

 ButtonText.text = LocalizationResourceManager.GetLocalizedValue("Button_Text");

An error is occurring:

Error  9   'System.Web.UI.HtmlControls.HtmlGenericControl' does not contain a definition for 'text' and no extension method 'text' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlGenericControl' could be found (are you missing a using directive or an assembly reference?)

What am I overlooking in this situation?

Answer №1

If you're unsure if your CSS is being applied to the button, consider using a span within a linkbutton instead:

<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>Click Here 2</span>
</asp:LinkButton>

Update:

<asp:LinkButton ID="Button1" runat="server" CssClass="Button1">
<span>
<asp:Label ID="ButtonText" runat="server" ></asp:Label>
</span>
</asp:LinkButton>

This modification should meet your requirements.

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

Fetching a precise element in Javascript

I have a question about handling AJAX requests. Specifically, when I send the request and it is successful, it returns a value. For instance: $('#content').load(url, function (info) { }) In this code snippet, the variable info contains the HTM ...

Setting the names to 'utf8' that contains variables

<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "membership"; $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); /* check connection */ if (mysqli_c ...

Struggling to access serialized values when deserializing a JSON array using Unity's JsonUtility

My current task involves deserializing card data from a JSON file to use in a Unity game, but I'm encountering some issues. Despite successfully testing the classes for deserialization and manually creating objects of them, the deserializer fails to p ...

Navigate directly to the section on the page that discusses the hashtag

So, I have a unique scenario to address. I'm working with two div elements where only one should be visible at a time. Here's the situation: The first div serves as an introduction page with a button that hides it and reveals the second div. Th ...

What is the best way to ensure that an iframe adjusts its height to fit the content within a tabbed container?

Is there a way to dynamically set the height of an iframe to match the content inside it when clicking on a tabbed plane? Initially, I used a fixed height of 1000px. How can this be achieved? <div class="container-fluid text-center"> <div ...

Adding audio to HTML using PHP in Internet Explorer and Firefox

I am working on developing an audio captcha system specifically for individuals with visual impairments. I have a process in place that stitches together multiple wave files, but I am encountering difficulties when it comes to embedding them in internet e ...

smtpclient is experiencing a delay when attempting to send an email through Office 365

This piece of code is what I'm using to send emails through the Office 365 exchange server. var server = "smtp.office365.com"; var port = 587; var username = "<a href="/cdn-cgi/l/email-protection" class="__cf_ ...

React app version displaying incorrect links to CSS and JS files

I have been immersed in a React project called Simple-portfolio, you can find the GitHub repository here: https://github.com/Devang47/simple-portfolio and the live site at this URL: While everything works smoothly on the development server, I encountered ...

Modifying the value of an animated status bar using the same class but different section

I need the status bars to work individually for each one. It would be great if the buttons also worked accordingly. I have been trying to access the value of "data-bar" without success (the script is able to process the "data-max"). However, the script see ...

Using Angular's ng-style directive to apply various styles based on multiple conditions and attributes

I am attempting to apply multiple styles to an accordion group using the ng-style directive since ng-class is not compatible with accordions. Here is my current implementation: ng-style="{ border: ivrMessageForm.ivr_messagetitle.$error.required && ...

Binding the Enabled attribute of a control to a text-based field

In my C#.NET project, I am utilizing strongly-typed DataSets, TableAdapters, and UserControls for managing record editing through BindingSources. A question has arisen in my mind about the possibility of dynamically enabling or disabling the Enabled proper ...

Having trouble with getting the second JavaScript function to function properly?

I am facing an issue with the second JavaScript function. When I click the 'Send Mail' button, it should call the second function and pass it two values. However, the href line (second last line in the first function) is not rendering correctly. ...

Tips for redirecting JavaScript requests to the target server using curl on a server

Currently, I am running a crawler on my server and require the execution of JavaScript to access certain data on the target site that I want to crawl. I recently had a question about a different approach to this issue, but for now, I need help with the fol ...

The React JSX error message "Maximum update depth exceeded" occurs when there

It appears that I am facing an issue of creating an infinite loop while passing props from one class to another. Despite ensuring that the buttons are correctly bound and trigger only once, the problem persists without any solution in sight after thorough ...

SQL post commenting management system: aggregating all comments to a single post

What I'm Looking for: I am looking to display all comments related to a specific post directly under that post. This can be achieved by using a loop to showcase all the CommentTexts in a list. For instance, if there are 3 comments with PostNr = ...

CSS margin to the left of every navigation bar button

On smaller screens, I updated my navbar buttons to be vertical using a media query. However, I encountered an issue where there is blank space to the left of each button despite not having a left margin in my code. Any help on how to resolve this would be ...

Converting Umbraco Json to a CSS class named "[]"

I'm currently using Umbraco with the data-type grid layout and I am trying to add custom settings (CSS classes) to each row/cell. The results are somewhat working, but I want to improve it. Here's the user interface: https://i.stack.imgur.com/iY ...

Activate the checkbox input by defining the form type with Javascript

I am attempting to control the enabling or disabling of input types based on whether a checkbox is checked or unchecked using JavaScript. Here is the code I am using: <script language="JavaScript"> <!-- function enable_text(status) { status=!st ...

Is it possible for JSON deserialization to fail within a Controller action, yet succeed when performed explicitly?

Seeking clarification on a matter that has puzzled me. While my controller actions usually handle JSON deserialization to C# objects smoothly, there is currently an issue I am grappling with. Instead of producing the expected outcome, it presents a QBWebho ...

Meta tags are causing issues with HTML5 validation on the website

Striving to enhance the HTML validity of my website, I encountered several errors in the meta tags that are marked as invalid. Unfortunately, I am unsure how to modify them to rectify these errors. <meta http-equiv="X-UA-Compatible" content="IE=edge,ch ...