"Implementing a form group in Bootstrap to separate a textbox from a

I'm currently working on creating a form-group that contains a textbox and a button using asp.net and bootstrap.

Here is the code snippet:

<div class="col-sm-4 col-md-4 col-lg-4 input-group">
    <asp:TextBox ID="txtPN" runat="server" placeholder="Search" CssClass="form-control" ClientIDMode="Static" />
    <span class="input-group-btn">
        <asp:Button ID="btnSearchPN" runat="server" Text="Search" CssClass="btn btn-default" />
    </span>
</div>

Initially, everything appears to be working well:

https://i.sstatic.net/UWwAi.png

However, when I resize the browser window, the textbox and the button seem to separate:

https://i.sstatic.net/AHMiJ.png

This form group is nested within

<div class="container-fluid"/>
. The complete code can be seen below:

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-4 col-md-4 col-lg-4 form-group">
            <label for="cbMarcas">Select Brand:</label>
            <asp:DropDownList ID="cbMarcas" CssClass="form-control" runat="server" ClientIDMode="Static" DataTextField="Description" DataValueField="Id" OnSelectedIndexChanged="cbMarcas_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
        </div>

        <div class="col-sm-4 col-md-4 col-lg-4 form-group">
            <label for="cbModelos">Select Model:</label>
            <asp:DropDownList ID="cbModelos" CssClass="form-control" runat="server" ClientIDMode="Static" DataTextField="Description" DataValueField="Id"></asp:DropDownList>
        </div>

        <div class="col-sm-4 col-md-4 col-lg-4 input-group">
            <asp:TextBox ID="txtPN" runat="server" placeholder="Search" CssClass="form-control" ClientIDMode="Static" />
            <span class="input-group-btn">
                <asp:Button ID="btnSearchPN" runat="server" Text="Search" CssClass="btn btn-default" />
            </span>
        </div>
    </div>
</div>

Any ideas on what could be causing this issue?

Answer №1

Instead of using all col-sm-4, col-md-4... you can simply specify xs for consistent widths across different screen sizes.

If you are working with the default .NET WebForms template, chances are you have the following in your site.css:

input,
select,
textarea {
    max-width: 280px;
}

To remove the max-width property, you need to create your own CSS code:

#txtPN {
    max-width: initial;
}

Answer №2

In an ASP.NET application, the standard Content/Site.css stylesheet limits the width of text inputs to 280px. However, if you decide to modify or delete this rule, your text input fields will expand to fill their container.

input[type="text"],
input[type="password"] {
    /*max-width: 280px;*/
}

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

What could be causing this modal form to redirect to my PHP file unexpectedly?

I've been struggling with integrating a form from another website into my new site. It doesn't seem to be working properly, and I'm wondering if there's something I'm missing. Could it be that the form needs to be used differently ...

Receiving an error message stating that 'tinymce.init is not a function' while attempting to browserify tinymce

I am having trouble getting a basic tinymce call to work with browserify. When I load tinymce from a CDN, it works perfectly fine. Below is a simplified example of what I am attempting to do. // main.js var tinymceConverter = require('./modules/tinym ...

Modifying the HTML content of a span element does not always initialize all of its properties

I've been working on setting up a comments-reply system for my website. I have all the necessary PHP files in place, but I'm facing an issue with updating the vote counts dynamically. In the image provided, you can see that upon voting once, I a ...

Locked first row and first column in HTML table

I'm struggling with freezing the first row and column in an HTML file exported from Microsoft Excel. When attempting to add position:fixed; to achieve this, I noticed that it changes the size and alignment of the headers. Can someone please advise me ...

Bottom line - incorporate two contact paragraphs with a separation in between the two sets of info

Greetings to all users of the web, I am encountering a perplexing issue. Here is my HTML code: #footer { position: absolute; left: 500px; bottom: 0px; } .contact_footer{ float: left; display: inline; } <footer> <div id="footer"> & ...

The SignalR server abruptly terminates the connection as soon as the client establishes it

Struggling with using SignalR in my project to send reboot messages to devices, I encountered a roadblock in the form of a SocketException: SocketException (0x80004005): An existing connection was forcibly closed by the remote host Determined to find a s ...

What could be causing the data retrieved from the JSON action to appear as "undefined"?

Have you examined the console.log() outputs and table structure for correctness? I suspect an error in one of them. I am fetching data from the database and using console.log() to display both the data in the loadData() function and value in the $.each(). ...

"Troubles with directing on websites using jQuery, CSS,

I have been struggling with creating this navigation bar for weeks now and I keep running into issues. What I am attempting to achieve is a primary navigation bar that, when hovered over, displays a secondary navigation menu below and slightly to the righ ...

Request for a unique identifier generating an array of all IDs in .NET Core MVC

While looping through my model to create a table, I encountered an issue with my delete function. Instead of returning the singular clicked item ID upon deletion, it is giving me back an array of all IDs. <tbody id="itemTable"> ...

What steps can be taken to avoid the div sidebar overlapping with the content on the

I am currently facing an issue with my website where the div sidebar scrolls with the page and overlaps the page content whenever the window is resized. To see a demonstration of the problem, you can visit this link: Below is the CSS code for the menubar ...

"Encountering a bad request error while making a cURL call in

Attempting to execute the below cURL command in a C# .NET environment curl -XPOST -d 'Metadata/Type = "sas"' http://bms.org/bcknd/republish The C# implementation is as follows: var requestContent = new FormUrlEncodedContent(new[] { new KeyValu ...

Slides on xaringan with the ability to scroll horizontally

I am interested in displaying the output of an R command within a horizontally scrolling box. See below for an example: library(ggplot2movies) head(movies) # title year length budget rating votes r1 r2 r3 r4 r5 r6 r7 r8 ...

Tips for closing a sidecart by clicking outside of it

I am currently exploring how to implement the functionality of closing my sidecart when I click outside of it. Below is the script I am using: const toggler = document.getElementById('menu-toggle'); const cartWrapper = document.getElementById( ...

Transmit the Model as a list from the View to the Controller with an ajax request

I am facing an issue when attempting to send my entire model, which is a List<Account>, using an ajax call. Below is the code snippet: @model List<ValidationAccount> <input type="button" id="SubmitAccounts" value="Final Proceed"> $("# ...

The chosen value in Select2 does not display in the order it was selected, but rather

I recently encountered an issue with a third-party plugin created by Ivan Vaynberg. When using the multiselect feature in select2, I noticed that the select2("val") method returns selected values in sorted order, rather than reflecting the order in which t ...

Are Bind() and Eval() functions equipped with automatic HtmlEncode to guard against XSS attacks?

I have a question that has been on my mind for quite some time now. I haven't found a clear answer to it yet, so please bear with me. In my aspx pages, instead of using Bind() or Eval(), I prefer using the following syntax within an ItemTemplate in a ...

"What is the best way to enforce a mandatory textbox in an alertify prompt using the HTML 5 required

Currently, I am implementing jQuery alertify prompt which can be found at Is there a method to require the textbox by setting attributes directly? Appreciate your assistance! ...

If the user confirms it with a bootstrap dialog box, they will be redirected to the corresponding links

Firstly, I am not interested in using javascript confirm for this purpose. Please read on. For example, adding an onClick attribute to each link with a function that triggers a system dialog box is not what I want. Instead of the standard system dialog bo ...

Activation code for the "Delete" key prompts the browser's return function - jQuery

I'm currently working on creating a digital keyboard that associates images with keycodes and adds them as spans after a keydown event. However, I have run into an issue with the DELETE feature. if (e.keyCode == 8) { $('span:last').remo ...

Navigate away from navbar using Bootstrap 4 tab links

In my tabbed interface, I am trying to create a link in one tab that will switch to another tab without being located in the navigation bar. Essentially, I want an external URL that can change the active tab. This is how my current code looks: <nav cl ...