Adding foreach loop in my view Razor page - html

I use the below code for my view Razor page and it works completely, but when I added my foreach loops based on my project's needs ,It does not show anything when I run the project. I want to help me to find my error in order to fix post form tag functionality.
#page
#model PracticeWithVideo.Pages.Admin.Order.ManageOrderModel
<h1
class="text-primary py-3">Manage Order's</h1> <form method="post">
<div class="container row bg-white p-2 mb-3 rounded">
<div class="col-12 pb-3 pt-3 mt-4 border rounded">
<div class="row">
<div class="col-4">
Order Number : xxx
<ul class="text-info">
</ul>
</div>
<div class="col-4 pb-2">
<div class="input-group pb-2">
<div class="input-group-append">
<span class="input-group-text bg-secondary border">Time</span>
</div>
<input type="text" class="form-control" readonly />
</div>
<textarea readonly class="rounded border form-control" rows="3"></textarea>
</div>
<div class="col-3 offset-1 d-flex align-content-center">
<div class="col-12">
<button type="submit" class="btn btn-primary form-control mb-3">
<i class="bi bi-check-square"></i> Start Cooking
</button>
<button type="submit" class="btn btn-success form-control mb-3">
<i class="bi bi-emoji-laughing"></i> Order Ready
</button>
<button type="submit" class="btn btn-warning form-control mb-3">
<i class="bi bi-x-square-fill"></i> Cancel Order
</button>
</div>
</div>
</div>
</div>
</div>
</form>
and this is my code with foreach loops:
#page
#model PracticeWithVideo.Pages.Admin.Order.ManageOrderModel
<h1 class="text-primary py-3">Manage Order's</h1>
<form method="post">
<div class="container row bg-white p-2 mb-3 rounded">
#foreach (var item in Model.OrderDetailVM)
{
<div class="col-12 pb-3 pt-3 mt-4 border rounded">
<div class="row">
<div class="col-4">
Order Number: #item.OrderHeader.Id
<ul class="text-info">
#foreach (var details in item.OrderDetails)
{
<li>#details.Name x #details.Count</li>
}
</ul>
</div>
<div class="col-4 pb-2">
<div class="input-group pb-2">
<div class="input-group-prepend">
<span class="input-group-text bg-secondary border">Time</span>
</div>
<input type="text" value="#item.OrderHeader.PickUpTime" class="form-control" readonly />
</div>
<textarea readonly asp-for="#item.OrderHeader.Comments" class="rounded border form-control" rows="3"></textarea>
</div>
<div class="col-3 offset-1 d-flex align-content-center">
<div class="col-12">
<button type="submit" class="btn btn-primary form-control mb-3">
<i class="bi bi-check-square"></i> Start Cooking
</button>
<button type="submit" class="btn btn-success form-control mb-3">
<i class="bi bi-emoji-laughing"></i> Order Ready
</button>
<button type="submit" class="btn btn-warning form-control mb-3">
<i class="bi bi-x-square-fill"></i> Cancel Order
</button>
</div>
</div>
</div>
</div>
}
</div>
</form>

Related

What must I add/remove to make this button the same size as the input field?

I am creating a basic landing page and I am adding a small newsletter signup component. When adding the bootstrap input group template, the button comes out much larger than the input field.
This is the code so far:
<!-- Newsletter -->
<section class="bg-primary text-light p-5">
<div class="container">
<div class="d-md-flex justify-content-between align-items-center">
<h3 class="mb-3 mb-md-0">Sign up for our Newsletter</h3>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-dark btn-lg" type="button">Button</button>
</div>
</div>
</div>
</div>
</section>
This is the specific input group code:
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-dark btn-lg" type="button">Button</button>
</div>
</div>
You can try to adjust the input field by adding a height on it. Like below
input.form-control {height: 38px}
<!-- Newsletter -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<section class="bg-primary text-light p-5">
<div class="container">
<div class="d-md-flex justify-content-between align-items-center">
<h3 class="mb-3 mb-md-0">Sign up for our Newsletter</h3>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-dark " type="button">Button</button>
</div>
</div>
</div>
</div>
</section>
You didn't do anything wrong. You either have to drop btn-lg class on the button or add input-group-lg alongside with input-group class. Both solutions are valid
here is an example of both solutions:
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<h2>Large form input</h2>
<section class="bg-primary text-light p-5">
<div class="container">
<div class="d-md-flex justify-content-between align-items-center">
<h3 class="mb-3 mb-md-0">Sign up for our Newsletter</h3>
<div class="input-group input-group-lg mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-dark btn-lg" type="button">Button</button>
</div>
</div>
</div>
</div>
</section>
<h2 class="mt-5">Small form input</h2>
<section class="bg-primary text-light p-5">
<div class="container">
<div class="d-md-flex justify-content-between align-items-center">
<h3 class="mb-3 mb-md-0">Sign up for our Newsletter</h3>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-dark" type="button">Button</button>
</div>
</div>
</div>
</div>
</section>

the html text input that i create using jquery and add more button is not sending any value in post method

i have a simple question hope you can help me .
I have a form and there are some in put fields that i add by addmore button .. but when i add file and descriptions it s not sending values..here is my form
<div class="row clone">
<div class="col-md-6">
<label class="mr-2 ml-2">Görsel</label>
<div class="input-group control-group ml-2">
<input type="file" name="image_name[]" class="form-control">
</div>
</div>
<div class="col-md-6">
<label class="mr-2 ml-2">Meta Açıklama</label>
<div class=" input-group mr-2 ">
<input type="text" name="image_description[]" class="form-control">
<span id="addFile" class="btn btn-success ml-2 mr-2">
<i class="fa fa-plus-circle "></i></span>
</div>
</div>
</div>
<div class="hidden row" style="display:none;">
<div class="row removeable col-md-12">
<div class="col-md-6 ">
<label class="mr-2 ml-2">Görsel</label>
<div class="input-group ml-2">
<input type="file" class="form-control" name="image_name[]">
</div>
</div>
<div class="col-md-6">
<label class="mr-2 ml-2">Meta Açıklama</label>
<div class="input-group control-group ml-2 ">
<input type="text" name="image_description[]" class="form-control" >
<span class="btn btn-danger ml-2 mr-1 removeBtn">
<i class="fa fa-times"></i></span>
</div>
</div>
</div>
</div>
and i create this extra file input by addmore button with jquery below
$("#addFile").click(function() {
var lsthmtl = $(".hidden").html();
$(".clone").append(lsthmtl);
});
$("body").on("click", ".removeBtn", function() {
$(this).parents(".removeable").remove();
});
but when i checked the request , only first file and description input values are coming..the inputs that i created by addmore button are nt sending values.Is there anyone have any idea ??

No POST request when submitting form

The following is signup.html when a user fills the form fields then presses on the button or pressing the ENTER key nothing happens and Flask only shows the GET requests that were made to get the page before filling users
No POST request is being made
changing action="{{url_for('UI.signup')}}" TO action='/signup' does not fix the problem
{% block content%}
<section class="vh-100" style="background-color: #eee;">
<div class="container h-100">
<div class="row d-flex justify-content-center align-items-center h-100">
<div class="col-lg-12 col-xl-11">
<div class="card text-black" style="border-radius: 25px;">
<div class="card-body p-md-5">
<div class="row justify-content-center">
<div class="col-md-10 col-lg-6 col-xl-5 order-2 order-lg-1">
<p class="text-center h1 fw-bold mb-5 mx-1 mx-md-4 mt-4">Sign up</p>
<form action="{{url_for('UI.signup')}}" method="POST" class="mx-1 mx-md-4" >
<div class="d-flex flex-row align-items-center mb-4">
<i class="fas fa-user fa-lg me-3 fa-fw"></i>
<div class="form-outline flex-fill mb-0">
<input name="username" type="text" id="form3Example1c" class="form-control" />
<label class="form-label" for="form3Example1c">Username</label>
</div>
</div>
<div class="d-flex flex-row align-items-center mb-4">
<i class="fas fa-envelope fa-lg me-3 fa-fw"></i>
<div class="form-outline flex-fill mb-0">
<input name="email" type="email" id="form3Example3c" class="form-control" />
<label class="form-label" for="form3Example3c">Email</label>
</div>
</div>
<div class="d-flex flex-row align-items-center mb-4">
<i class="fas fa-lock fa-lg me-3 fa-fw"></i>
<div class="form-outline flex-fill mb-0">
<input name='passwrd1' type="password" id="form3Example4c" class="form-control" />
<label class="form-label" for="form3Example4c">Password</label>
</div>
</div>
<div class="d-flex flex-row align-items-center mb-4">
<i class="fas fa-key fa-lg me-3 fa-fw"></i>
<div class="form-outline flex-fill mb-0">
<input name='passwrd2' type="password" id="form3Example4cd" class="form-control" />
<label class="form-label" for="form3Example4cd">Repeat your password</label>
</div>
</div>
<div class="d-flex justify-content-center mx-4 mb-3 mb-lg-4">
<button type="button" class="btn btn-primary btn-lg">Register</button>
</div>
</form>
</div>
<div class="col-md-10 col-lg-6 col-xl-7 d-flex align-items-center order-1 order-lg-2">
<img src="{{url_for('UI.static', filename='.jpg')}}" class="img-fluid" alt="Sample image">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock%}
I wish to use this exact html for the signin page but for some reason it is not creating post requests after filling the data
<button type="button" class="btn btn-primary btn-lg">Register</button>
type="button" creates a button that doesn't do anything. It exists solely to hook JavaScript onto.
Take that out (type="submit" is the default) and the button will submit the form when clicked.

Problem with Bootstrap 4 Responsive image (imag-fluid)

I created a login in page using a bootstrap grid with an image col-lg-8 and the form col-lg-4. The problem is that when I minimize the screen for smaller devices, the contents are supposed to respond and span 12 each as usual. However, the image always overflows to the top and is cut off. Yes, I used img-fluid on the image.
<section class="Form mx-4 h-100">
<div class="container h-100 d-flex">
<div class="row no-gutters h-80 align-self-center row-eq-height" id="slide-container">
<div class="col-lg-8 my-auto responsive py-5">
<img src="Athlete 1.png" alt="This is America" class="img-fluid border-right">
</div>
<div class="col-lg-4 px-4 my-auto sign-in sign-in-up">
<div class="row no-gutters">
<div class="col-12 d-flex justify-content-center align-items-center">
<div class="col-2 px-0">
<img src="Athlete 3.png" alt="Logo" class="img-fluid rounded-circle">
</div>
<div class="col-7 align-self-center mb-0 px-0">
<h2>Side-Gym</h2>
</div>
</div>
<div class="col-12 text-center text-secondary mt-2">
<h4>Members Login</h4>
</div>
</div>
<form>
<div class="form-group">
<label for="email">Email</label>
<input type="email" placeholder="Enter Your Email..." name="email" id="email" class="form-control">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" placeholder="Password" name="password" id="password" class="form-control">
</div>
<button type="submit" class="btn btn-outline-primary btn-block mt-4 mb-1">Login</button>
<button type="button" class="btn btn-link btn-block" disabled>--------or--------</button>
<button id="register" type="button" class=" btn-regis btn btn-primary btn-block mt-1 mb-3">Register</button>
Forgot Password?
<div class="mb-4 textlink text-center formaer-dropdown">
<p class="d-inline">Don't have an account? </p>
Register Here!
</div>
</form>
</div>
</section>
If you really need height: 100vh; for the body add overflow-y: scroll; with it at #media(min-width: 992px) AND REMOVE all the h-100 & h-80 classes, otherwise the overflow-y: scroll; won't work

Bootstrap 4 column rows with buttons

I've started to explore Bootstrap 4 and HTML5/CSS in general. I want to create a text area with two buttons on the side (centered horizontally to each other) :
The code I got is the following:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<div class="container mt-2">
<div class="row">
<div class="col-10">
<textarea class="form-control" rows="3" id="sent_text" placeholder="Just write some text.."></textarea>
</div>
<div class="col-2">
<div class="row">
<button class="btn btn-success btn-sm m-1" type="button">Send</button>
</div>
<div class="row">
<button class="btn btn-info btn-sm m-1" type="button">Clear</button>
</div>
</div>
</div>
</div>
I've created a row with 2 columns in it. The second column contains two rows.
Is that correct way to go?
Thanks
A better way of doing it with justify-content-around d-flex flex-column on the buttons column. There was no need of additional row element in the col-2 div.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<div class="container mt-2">
<div class="row">
<div class="col-10">
<textarea class="form-control" rows="3" id="sent_text" placeholder="Just write some text.."></textarea>
</div>
<div class="col-2 justify-content-around d-flex flex-column">
<div>
<button class="btn btn-success btn-sm" type="button">Send</button>
</div>
<div>
<button class="btn btn-info btn-sm" type="button">Clear</button>
</div>
</div>
</div>
I think this method is way better. (:
Use col for the textarea column so that it takes all the available space.
Use col-auto for the buttons column so that it takes as much as space as it needs. And then use d-flex flex-column to change its direction.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<div class="container mt-2">
<div class="row">
<div class="col">
<textarea class="form-control" rows="3" id="sent_text" placeholder="Just write some text.."></textarea>
</div>
<div class="col-auto d-flex flex-column">
<button class="btn btn-success btn-sm m-1" type="button">Send</button>
<button class="btn btn-info btn-sm m-1" type="button">Clear</button>
</div>
</div>
</div>
You should place each button in a div with 'col-...' class.
Bootstrap documentation about nesting elements in a row
Codepen with your example to show you the difference when you use 'col-...' class.
Codepen
<div class="container mt-2">
<div class="row">
<div class="col-10">
<textarea class="form-control" rows="3" id="sent_text"
placeholder="Just write some text.."></textarea>
</div>
<div class="col-2">
<div class="row">
<button class="btn btn-info btn-sm m-1" type="button">Clear</button>
</div>
<div class="row">
<div class="col-12">
<button class="btn btn-success btn-sm m-1" type="button">Send in col</button>
</div>
</div>
<div class="row">
<div class="offset-6 col-6">
<button class="btn btn-success btn-sm m-1" type="button">Send centered using col</button>
</div>
</div>
</div>
Also making the textarea none-reziable is good.Thus
Try this
textarea.form-control{
resize: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<div class="container mt-2">
<div class="row">
<div class="col-10">
<textarea class="form-control" rows="3" id="sent_text" placeholder="Just write some text.."></textarea>
</div>
<div class="col-2">
<div class="row">
<div class="d-flex flex-column">
<button class="btn btn-success btn-sm m-1" type="button">Send</button>
<button class="btn btn-info btn-sm m-1" type="button">Clear</button>
</div>
</div>
</div>
</div>
</div>