Unable to reposition 'Select' element in ASP.net

Recently, I attempted to implement Bootstrap Dual Listbox for my project after finding it at this link: . However, I encountered an issue where the dual-list box consistently aligned to the left and I struggled to change its alignment. Despite trying to adjust the styling attributes within the 'select' element and linking to a CSS file, none of my attempts were successful.

<body>

       <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3' style="text-align:center">

        <% for(int i = 0 ; i <50; i++){ %>
        <option value="<%=i %>" ><%=i %></option>
        <% } %>

    </select>



    <script>
        var demo2 = $('.demo2').bootstrapDualListbox({
            nonselectedlistlabel: 'Select',
            selectedlistlabel: 'Selected',
            preserveselectiononmove: 'moved',
            moveonselect: false,
            initialfilterfrom: ''
        });
    </script>
    <script src="libraries/jquery-placeholder/jquery.placeholder.js"></script>
    <script>
        $('input').placeholder();
        prettyPrint();
    </script>
</body>

The current appearance can be viewed here: (aligned to the left instead of center). How can I go about resolving this issue?

Your assistance is greatly appreciated!

Answer №1

To center the content, consider enclosing it in a container with text alignment set to center:

<div style="width:100%; text-align:center;">
    <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3'>
        ...
    </select>
</div>

Answer №2

To properly style your <Select> element, wrap it in a container div and apply the following CSS styles to the container:

display: table;
margin: 0 auto;

Your code should resemble this example:

<div style="display: table; margin: 0 auto;">

    <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3'>
        <!-- your content here -->
    </select>

</div>

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

Adjust the visibility of components depending on the width of the screen

In my project, I have a Wrapper component that houses filters. This component becomes visible when the openMobileFilters() function is called and disappears when closeMobileFilters() is triggered. The Wrapper component occupies the entire page, and I want ...

Will the referrer site show up on Google Analytics for example.com if I use rel="nofollow"?

Will adding a rel="nofollow" tag prevent the referrer site from showing up on Google Analytics for example.com? For example: The referrer site is: referrer.com <a href="example.com" rel="nofollow"></a> ...

Ajax request results in a 400 error code

Here is the structure of my Ajax call: function Submit() { var objectData = { email: $("#email").val(), firstName: $("#firstName").val(), lastName: $("#lastName").val(), loginMode: $("#login ...

Using Mat-Error for Two Way Binding leads to frequent triggering of ngModelChange事件

I am working with a mat input field that has two-way data binding using ngModel, and I want to add validation using mat-error and formControl. <mat-form-field [formGroup]="myForm"> <input matInput formControlName="myFormName" autocomplete="off" ...

issue involving extension that interrupts downloads

Trying to develop a browser extension that can intercept downloads and automatically rename them. manifest.json: { "name": " Book Renamer", "description": "Automatically rename downloaded ebooks from gutenberg.or ...

producing base64 encoding that results in a blank image

I have some code that is supposed to get an image from a video using canvas. However, when I save this base64 code into an image, I end up with a black image. What could be causing this issue? Here is my JavaScript code: var input = document.getElementBy ...

Stop Form Submission in Bootstrap 5

I require assistance with identifying the issue in the JavaScript code provided below. I am working with a Bootstrap 5 form where the submission is not being prevented if the fields are left blank or invalid. While the HTML/CSS validation works correctly f ...

Erroneous deletion issue in React list causing removal of incorrect item

While working on creating a todo list in React, I faced an issue when trying to implement a delete function. The problem arose when attempting to delete an item - instead of removing the selected item, React ended up deleting everything except that specif ...

Using Jquery to select the parent element and then adding a CSS selector to it

I am currently exploring the most effective approach to accomplish this task. My goal is to expand/collapse all hidden divs on a given page. While this is usually not an issue, I have four distinct sections that necessitate independent expand/collapse func ...

Is there a sophisticated CSS compressor that can eliminate unnecessary code and separate identical rules with commas?

Consider this input{margin:0}body{margin:0;background:white} can also be written as input,body{margin:0}body{background:white} or like this input,body{margin:0}body{margin:0;padding:0} and simplified to input,body{margin:0}body{padding:0} Bottom Li ...

"Enhance your mobile user experience with swipeJS integration in jQuery

Trying to incorporate swipeJS into my jQuery Mobile application has been challenging. Below is the code snippet from the page where I attempted to implement swipeJS: FULL CODE: http://jsfiddle.net/unTHs/ (output on jsfiddle may vary) <div id="slider" ...

Common issues encountered with Forms authentication in ASP.Net

Developing on Windows Server 2008 with VSTS 2008 + C# + .Net 3.5 to create an ASP.Net application using Forms authentication has been my latest project. I’ve been diving into Forms authentication by referencing materials from http://msdn.microsoft.com/en ...

Is Angular File API Support Compatible with HTML5?

When checking for HTML5 File API browser support in my code: private hasHtml5FileApiSupport; constructor(@Optional() @Inject(DOCUMENT) document: Document) { const w = document.defaultView; this.hasHtml5FileApiSupport = w.File && w.FileReader & ...

Grunt replace throwing an undefined destination error

I'm attempting to use grunt replace in order to modify file names and append a random number to prevent caching of images, CSS, and JS files. Here is the code I am running: module.exports = function replace(grunt) { var randomVersion = ((new Dat ...

How to design a dictionary schema using Mongoose

I have been attempting to save a dictionary of objects using Mongoose. Upon realizing that the change detection for saving is lost when using the Mixed type, I am looking for a way to create a schema that does not rely on the Mixed type. While there are m ...

Using jQuery to dynamically insert a table row with JSON data into dropdown menus

I'm working on a web form that includes a table where users can add rows. The first row of the table has dependent dropdowns populated with JSON data from an external file. Check out the code snippet below: // Function to add a new row $(function(){ ...

Transfer text with style from a JTextPane to Microsoft Word

I'm trying to transfer styled text from a JTextPane to Microsoft Word. My current code gets the job done, but it struggles with accented characters: Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard(); ByteArrayOutputStream ot = n ...

A guide on modifying the HTML code of a browser element using Python's Selenium

Does anyone have tips on how to edit the HTML code of a browser element using Selenium? I've been struggling to find a solution. Any advice would be greatly appreciated! ...

MongoError: Transaction could not be initiated

I recently delved into using mongoose transactions for the first time. Following the guidelines in the documentation and some related articles, I managed to get it up and running with the help of run-rs for local replicas. However, I encountered a couple o ...

The JavaScript-set value in a form field is not being transmitted to the PHP script within the $_POST array

Struggling to pass a JavaScript value to a .php script, and then on to a .txt script. It works fine with regular numbers, but when trying with the variable it fails, leaving the .txt file blank. Despite extensive research online, I can't seem to get i ...