MVC logout Button Confirm Modal Popup Not working - css

Im develop the MVC project, Im developed the User Login session, Im add the user logout button for bootstrap modal popup confirmation box, but box is not working,How can i fix it.
Thank you
<header>
<a id="header-logo" href="#"></a>
<a class="navbar-brand" href="#"><img src="~/img/ekinitting _logo.png" class="img-responsive" style=" position: absolute; display: block; width: 260px; height: 65px; left: 10px; top: 10px;"></a>
#using (Html.BeginForm("LogOut", "Login", new { area = "" }, FormMethod.Post, new { id = "logoutForm" })){
#Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()" style=" top:-28px;"><input type="image" id="myimage" src="~/img/log_out.png" style=" margin-top:15px; margin-left:150px; position:relative; float:right; " data-toggle="modal"
data-target="#basicModal" /></a>
}
<div class="col-lg-2" style="color:#ff0000; margin-top:28px; left:1055px; position:relative; ">
#Html.ActionLink("Hello " + ((eKnittingData.UserRegistration)Session["User"]).UserName + " :)", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Welcome", style = "color:#fada5b; text-decoration: none; font-size:14px;" })
</div>
<!--/.nav-collapse -->
<a href="~/Home/Index">
<input type="image" id="myimage" src="~/img/Red-home-icon.png" style="top:15px; position:relative; left:150px; float:right; " />
</a>
</header>
Modal
<div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content" style="background-color:#ffffff; border:solid 4px #e85656;margin-top:253px; left:-25px;">
<div class="modal-header" style="background-color:#e85656; height:15px;">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-top:-12px;">x</button>
<span class="glyphicon glyphicon-warning-sign" style=" color:yellow; font-size:large; top:-10px; left:115px;" aria-hidden="true"></span>
<h4 class="modal-title" id="myModalLabel" style="text-align:center;"></h4>
</div>
<p style="text-align:center; font-family:'Ebrima'; color:black; margin-top:15px;"> <strong> Are you sure you want to logout? </strong></p>
<div class="modal-footer" style="text-align:center;">
<button type="button" class="btn btn-success btn-xs" style=" width:50px;">Yes</button>
<button type="button" class="btn btn-danger btn-xs" data-dismiss="modal" style=" width:50px;">No</button>
</div>
</div>
</div>
</div>

You should place your form inside the modal not to the logout button which is opening the modal.
Just put the form in the modal-body where the confirmation text is written in your code.
All you need to put the form outside to the modal-body and footer div.

Related

How can I make my tabs consistent with CSS?

I have implemented an UI. There I have 4 tabs.
The gap between the tabs are different(inconsistent) and If I try to make width to auto, then the indicator below the tab is not displayed.
code for the tabs -
<div class="MuiTabs-flexContainer" role="tablist">
<button class="MuiButtonBase-root MuiTab-root jss2 MuiTab-textColorInherit Mui-selected" tabindex="0" type="button" role="tab" aria-selected="true">
<span class="MuiTab-wrapper">Aikika</span>
<span class="MuiTouchRipple-root"></span>
</button>
<button class="MuiButtonBase-root MuiTab-root jss2 MuiTab-textColorInherit" tabindex="-1" type="button" role="tab" aria-selected="false">
<span class="MuiTab-wrapper">Qwertyuio</span>
<span class="MuiTouchRipple-root"></span>
</button>
<button class="MuiButtonBase-root MuiTab-root jss2 MuiTab-textColorInherit" tabindex="-1" type="button" role="tab" aria-selected="false">
<span class="MuiTab-wrapper">Plmojnuhbtf</span>
<span class="MuiTouchRipple-root"></span>
</button>
<button class="MuiButtonBase-root MuiTab-root jss2 MuiTab-textColorInherit" tabindex="-1" type="button" role="tab" aria-selected="false">
<span class="MuiTab-wrapper">Tokjl Test</span>
<span class="MuiTouchRipple-root"></span>
</button>
</div>
and code for indicator ( underline below to the tab )-
<span class="jss3 jss5 MuiTabs-indicator jss1" style="left: 0px; width: 120px;"></span>
CSS code is -
.MuiTabs-flexContainer button {
min-width: 120px;
font-weight: 100;
margin-top: 8px;
}
CSS code for indicator -
.jss1 {
height: 3px;
background-color: #09728e;
}
Currently everything working fine but gap between the tabs are inconsistent. I want my tab to be consistent and indicator should also work fine. I have attached the screenshot for the reference. Red box showing the gap between tab & blue line showing the indicator below the tabs.
You can try to do something like this:
.MuiTabs-flexContainer{
display: flex;
align-items: center;
justify-content: space-between;
}

match the design to iphone4 & iphone 5

I have problem to match the buttons to iphone 4 and iphone 5 only.
all the other platform design phones looks good and responsive but only iphone 4 & 5 little strange.
as you can see in nexus, galaxy and iphone 6 it looks good
but in iphone 4 i need to scroll down and the forgot password and create account is one on the other.
<div class="popup popup-login modal-{{popupLogin}}" style="display: block;background:transparent">
<div class="content-block" >
<div class="login-view-box page page-login-wrapper" style="background:transparent;background:#009688">
<div class="text-center" >
<div class="logo sd" ></div>
<div class="company-text">company name</div>
</div>
<div class="list login-form-box">
<form name="loginForm"
novalidate ="novalidate"
ng-submit="loginForm.$valid && performLogin()" style="margin:20px auto;">
<label class="item item-input" >
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
fill="#000000"></path>
</svg>
<input type="email" placeholder="Email" name="email" ng-model="email" ng-class="{submitted:submitted}" required/>
</label>
<div ng-messages="loginForm.email.$error" ng-if="loginForm.email.$touched || submitted" class="input-error-small item item-input">
<div ng-message="required">{{ClientMessages.ThisFieldCannotBeEmpty}}</div>
<div ng-message="email">{{ClientMessages.InvalidEmailInput}}</div>
</div>
<br />
<label class="item item-input">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 20 20">
<path d="M14.5 8h-0.5v-1.5c0-2.481-2.019-4.5-4.5-4.5s-4.5 2.019-4.5 4.5v1.5h-0.5c-0.827 0-1.5 0.673-1.5 1.5v8c0 0.827 0.673 1.5 1.5 1.5h10c0.827 0 1.5-0.673 1.5-1.5v-8c0-0.827-0.673-1.5-1.5-1.5zM6 6.5c0-1.93 1.57-3.5 3.5-3.5s3.5 1.57 3.5 3.5v1.5h-7v-1.5zM15 17.5c0 0.276-0.224 0.5-0.5 0.5h-10c-0.276 0-0.5-0.224-0.5-0.5v-8c0-0.276 0.224-0.5 0.5-0.5h10c0.276 0 0.5 0.224 0.5 0.5v8z"
fill="#000000"></path>
</svg>
<input type="password" placeholder="Password" name="password" ng-model="password" ng-class="{submitted:submitted}" required/>
</label>
<div ng-messages="loginForm.password.$error" ng-if="loginForm.password.$touched || submitted" class="input-error-small item item-input">
<div ng-message="required">{{ClientMessages.ThisFieldCannotBeEmpty}}</div>
</div>
<button type="submit"
class="button button-block button-positive"
id="login-button"
ng-click="loginSubmit()"
<i class="icon ion-loading-c"></i>
<span>Sign In</span>
</button>
<div class="item item-input list-block" style="background-color:transparent;border:0;margin-top:8px;" ng-click="toggleStayLoggedCheck();" >
<label class="label-checkbox">
<input type="checkbox" name="stayLoggedCheckbox" ng-model="stayLoggedCheckbox" value="StayLogged" >
<div class="item-media" style="padding-left:20%">
<i class="icon icon-form-checkbox" style="border-radius:0"></i>
<span style="padding-left:10px;color:white">Stay Logged In</span>
</div>
</label>
</div>
</form>
<button class="button btn-account">
Create an account
</button>
</div>
<!-- Big Button -->
<div class="footer-link text-center" style="margin-top:20px;">
<div class="text-center" style:"margin-top:20px;">
<a href="#" class="open-popup" data-popup=".popup-forgotpassword" style="color:white;">
Forgot Password?!
</a>
</div>
<!-- <a href="#" class="open-popup" data-popup=".popup-register" >
I don't have a APP account.
</a>-->
</div>
<div class="text-center crt"
style="position: absolute;
background: #4bd46b;
border-radius: 20px;
height: 40px;
width: 40px;
bottom:10px;
right:10px;
font-size: 18px;">
<span class="fa fa-envelope-o df-color" style="font-size:20px;top:8px;position:relative;"></span>
</div>
</div>
</div>
</div>
the problem area
<button class="button btn-account">
Create an account
</button>
</div>
<!-- Big Button -->
<div class="footer-link text-center" style="margin-top:20px;">
<div class="text-center" style:"margin-top:20px;">
<a href="#" class="open-popup" data-popup=".popup-forgotpassword" style="color:white;">
Forgot Password?!
</a>
</div>
<!-- <a href="#" class="open-popup" data-popup=".popup-register" >
I don't have a APP account.
</a>-->
</div>
<div class="text-center crt"
style="position: absolute;
background: #4bd46b;
border-radius: 20px;
height: 40px;
width: 40px;
bottom:10px;
right:10px;
font-size: 18px;">
<span class="fa fa-envelope-o SAMGray-color" style="font-size:20px;top:8px;position:relative;"></span>
</div>
Has your class .footer-link a position: absolute and bottom: 0 properties or something ?
I'd suggest to create a media query like below, to target iphones 4 & 5.
#media only screen and (max-width: 320px) {
/* your iphone 4 & 5 styles */
}
Then, switch your .footer-link class to position: relative (and maybe float: left, depending on your other blocks' float).
The final code should looks like this:
#media only screen and (max-width: 320px) {
.footer-link {
position: relative;
/* float: left; if needed */
}
}
This should position the "forgot password" and fab below the "create account" button and in the meantime apply that margin-top: 20px which is useless in absolute positionning.
Your view will have to be scrolled to see the "forgot password" link though. So you might want to add more styles to the media query in order to reduce some margins, paddings or font-sizes and get the desired view as a result.
However, in this layout your fab link will be messed up. As its absolute positionning would be relative to the .footer-link. I suggest you move it outside of the footer (right before the </body> tag, for example).
Hope this helps!
I'd try switching the position properties. When positioning something absolute, the parent should be "position:relative". When you were resizing in Chrome's mobile spoofer, it was pushing that absolute positioned item up and into the other content. It isn't mimicking any other specs when you're spoofing the view, just the view dimensions. Hope this helps!
<div class="text-center crt" style="position: relative;
background: #4bd46b;
border-radius: 20px;
height: 40px;
width: 40px;
bottom:10px;
right:10px;
font-size: 18px;">
<span class="fa fa-envelope-o df-color" style="font-size:20px;top:8px;position: absolute;"></span>
</div>

How to keep CSS blocks equal?

I am creating a virtual store where the main page shows the products, this is where the quantity of information in the detail of the product varies, the blocks begin to deform. How could you do to keep the size constant and in any case the text is truncated?
I'm working with MVC 5 and Bootstrap.
<!-- Bloque 1 -->
#foreach (var item in Model)
{
<div class="col-sm-3 col-lg-3 col-md-3">
<div class="thumbnail">
<!-- TRAE UNA IMAGEN DE CUALQUIER MANERA-->
<img src="#Url.Action("RenderImage", new { id = item.ProductoID})" alt="" width="150" height="320" />
<div class="panel panel-yellow">
<div class="panel-heading">
<h4 class="pull-right">$#item.PrecioUnitario</h4>
<h4>
<a href="#Url.Action("Detalle", new { id = item.ProductoID })" class="my-class">
#item.Nombre
</a>
</h4>
</div>
</div>
<div class="ratings">
#*<p>See more snippets like this online store item at <a target="_blank" href="http://www.bootsnipp.com">Bootsnipp - http://bootsnipp.com</a>.</p>*#
<p>#item.DetallesCorto</p>
</div>
<div class="ratings">
<p class="pull-right">15 Me gusta</p>
<p>
<span class="fa fa-fw fa-star"></span>
<span class="fa fa-fw fa-star"></span>
<span class="fa fa-fw fa-star"></span>
<span class="fa fa-fw fa-star"></span>
<span class="fa fa-fw fa-star"></span>
</p>
<p>
<button type="button" class="AddLink btn btn-block btn-success btn-xs" href="#" data-id="#item.ProductoID" data-toggle="modal" data-target="#myModal">
<i class="fa fa-fw fa-shopping-cart"></i> Agregar
</button>
</p>
</div>
<div class="ratings">
#if (Request.IsAuthenticated && User.IsInRole("Root") || User.IsInRole("Admin"))
{
<p>
<button type="button" class="anchorDetail btn btn-block btn-info btn-xs"
href="javascript:void(0);" data-id="#item.ProductoID">
<i class="fa fa-pencil"></i> Edicion rápida
</button>
</p>
<p>
<button type="button" class="popupDelete btn btn-block btn-danger btn-xs"
href="javascript:void(0);" data-id="#item.ProductoID">
<i class="fa fa-trash"></i> Eliminar
</button>
</p>
}
</div>
</div>
</div>
} <!-- Cierro Forech -->
</div>
That's how it looks now:
Solution 1 (CSS)
Set a fixed height on the red paragraph and the title and hide the overflow.
.thumbnail .ratings:nth-of-type(1) p {height: 100px; overflow: hidden;}
.thumbnail h4:nth-child(2) {height: 30px; overflow: hidden;}
Solution 2 (jQuery)
Create a javascript function setting the height equal to the tallest red paragraph and the tallest title.
var maxh = 0;
$('.thumbnail .ratings:nth-of-type(1) p').each(function() {
var h = $(this).height();
if(h > maxh) maxh = h;
});
$('.thumbnail .ratings:nth-of-type(1) p').css('height', maxh);
var maxh = 0;
$('.thumbnail h4:nth-child(2)').each(function() {
var h = $(this).height();
if(h > maxh) maxh = h;
});
$('.thumbnail h4:nth-child(2)').css('height', maxh);
You might be tempted to set a fixed height to the thumbnail div. But that will require you to set the rating stars and the green button to position: absolute; bottom: [amount]px; to align them properly. I am quite sure that is not compatible with the bootstrap floats and the responsive behaviour of these items.
You can loop through each .thumbnail item and find the max height, then apply a min-height to each element matching that max height:
$(document).ready(function() {
var maxHeight = 0;
$('.thumbnail').each(function() {
var height = $(this).height();
if(height > maxHeight) {
maxHeight = height;
}
});
$('.thumbnail').css('min-height', maxHeight);
});
You may need to utilize a delay such as setTimeout to ensure everything has been loaded prior to calculating the heights.
You should use rows or set equal height to all boxes with javascript/jquery. Bootstrap uses 12 cols per row so you could modify your code to separate by 4 items per row. Also you only need the smallest device col width if larger ones are same. In your case use col-sm-3 only.
<div class="row">
<div class="col-sm-3" ></div>
<div class="col-sm-3" ></div>
<div class="col-sm-3" ></div>
<div class="col-sm-3" ></div>
</div>
Give the boxes a set height for example:
.box {
height: 150px;
}

Align bootstrap dropdown in input-group to left (underneath the start of the input)

I have a input group (text input and button with dropdown). I am having trouble getting my dropdown to align with the text box.
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<input type="text" class="form-control" />
<div class="input-group-btn">
<div class="dropdown open">
<button class="btn btn-secondary dropdown-toggle"
type="button"
id="dropdownMenuButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false">
dropdown
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
I have tried <div class="dropdown-menu dropdown-menu-left"> with no avail.
Here is a fiddle
What do I need to add to this to align my dropdown menu to the left underneath the start of the input (as if it was a typeahead)?
EDIT: within the dropdown menu is an angular directive, that's likely a relative tool
Here is the Quick Fix
Working Demo Here
HTML:
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<div class="testing">
<input type="text" class="form-control" />
</div>
<div class="input-group-btn">
<div class="dropdown open">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="false" aria-expanded="false">dropdown</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
.testing {
position: relative;
}
JS:
$(document).ready(function() {
dropmenuWidgetPosition();
function dropmenuWidgetPosition() {
$('#dropdownMenuButton').dropdown('toggle');
$(window).on('show.bs.dropdown', function(e) {
var dropdownMenu = $(e.target).find('.dropdown-menu');
var dropMenuDetach = dropdownMenu.detach();
// detach it and append it to the target
$(e.target).parents('.input-group').eq(0).find('.testing').append(dropMenuDetach);
// grab the new offset position
var eOffset = $(e.target).offset();
// make sure to place it where it would normally go (this
// could be
// improved)
dropdownMenu.css({
'display': 'block',
'top': eOffset.top + $(e.target).outerHeight(),
'left': 0
});
});
// and when you hide it, reattach the drop down, and hide it
// normally
$(window).on('hide.bs.dropdown', function(e) {
var dropdownMenu = $(e.target).parents().find('.dropdown-menu');
var dropMenuDetach = dropdownMenu.detach();
$(e.target).append(dropMenuDetach);
dropdownMenu.hide();
});
}
});

Exception handling using the modal

There was such task.
I have a controller method of removing
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
try {
TechnologicalCard technologicalCard = db.TechnologicalCards.Find(id);
db.TechnologicalCards.Remove(technologicalCard);
db.SaveChanges();
return RedirectToAction("Index");
}
catch (Exception ex)
{
ViewBag.Error = true;
TempData["message"] = "someMessage";
return RedirectToAction("Index");
}
}
How can I do that would be when an exception is thrown during the removal of the modal appeared with warning text ?
UPDATE
I added the index method
public ActionResult Index()
{
var id_Head = User.Identity.GetUserId();
TempData["message"] = "someMessage";
var technologicalCards = db.TechnologicalCards.Where(c => c.IdHeadDepartment == id_Head).ToList();
return View(technologicalCards);
}
My view has contains the following code
#model IEnumerable<AccountingPlusProject.Models.TechnologicalCard>
#{
ViewBag.Title = "Учёт+";
}
<style>
.md-form {
position: relative;
top: 40px;
width: 20%;
height: 20%;
text-align: center;
}
.img1 {
background-image: url("/Content/avatars/Head.jpg");
background-repeat: no-repeat;
width: 7%;
height: 65px;
border-style: none;
margin-left: 90%;
margin-top: -8%;
}
.img2 {
width: 7%;
height: 65px;
border-style: none;
margin-left: 80%;
}
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
.demo-card-wide.mdl-card {
width: 512px;
}
.demo-card-wide > .mdl-card__title {
color: #fff;
height: 176px;
}
.demo-card-wide > .mdl-card__menu {
color: #fff;
}
.container {
margin: 30px auto;
width: 85%;
height: 100%;
}
.warningMessage {
font-weight: bold;
color: Red;
}
</style>
<script>
$(function () {
if ($('#myModal').length) {
$('#myModal').modal('show');
}
});
</script>
<nav class="navbar navbar-light teal lighten-4" style="height: 100px">
<div class="container">
<div class="collapse navbar-toggleable-xs" id="collapseEx2" style="margin-top:-2%">
<img src="~/Content/truelogo.png" style="margin-left:-10%" />
#Html.ActionLink("Добавить технологическую карту", "Create", null, new { #class = "btn btn-success" })
<img src="~/Content/avatars/Head.jpg" class="rounded-circle img-responsive img1">
#Html.ActionLink("Отмена", "Index", "HeadDepartment", null, new { #class = "btn btn-danger", #style = "margin-left:100%; margin-top:-11%" })
</div>
</div>
</nav>
<div class="page-content">
<div class="container">
#{int i = 1;}
<table>
#foreach (var item in Model)
{
if (i % 4 == 1)
{
<tr></tr>
}
<td>
<div class="card">
<img class="img-fluid" src="#item.Image" alt="Card image cap">
<div class="card-block">
<center>
<hr />
<h4 class="card-title">#item.NameProduct</h4>
<hr />
#item.Description
<hr />
#{ var materials = item.SelectedMaterials.ToList();}
#foreach (var material in materials)
{
#Html.DisplayFor(model => material.ReferenceMaterial.NameMaterial) <b> Штук: </b>
#Html.DisplayFor(model => material.CountMaterial)
<br />
}
<br />
<center>
#Html.ActionLink("Настроить материалы", "EditMaterial", new { id = item.IdTechnologicalCard }, new { #class = "btn btn-success" })
<br />
#Html.ActionLink("Настроить количество", "EditCountOfMaterial", new { id = item.IdTechnologicalCard }, new { #class = "btn btn-success" })
</center>
<hr />
#Html.ActionLink("Удалить", "Delete", new { id = item.IdTechnologicalCard }, new { #class = "btn btn-danger" })
</center>
</div>
</div>
</td>
i++;
}
</table>
</div>
#if (TempData["message"] != null)
{
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria- labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
121212 <!--add your message here-->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data- dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
}
</div>
But when I deleting redirects to Index view without modal
You can pass error messages using the model state dictionary as well. In that case, you should be returning the same view back to the user instead of a redirect, so that user can try the action again.
catch (Exception ex)
{
ModelState.AddModelError(string.Empty,"Error! Try again.");
return View();
}
Now make sure you have the Validation helper methods being used in the view to render the error messages from the model state dictionary.
#Html.ValidationSummary(false)
With this approach, only the id will be passed back to the view (basically read from the model state dictionary), not all other fields you had. If you want all fields, use the same view model (which your view is strongly typed to) as the method parameter.
Exception handling using the modal
As you made it clear that you want to show the error in a modal window here is what you can do.
You need to again assign this TempData data into another TempData with in your Index method. Since the TempData is only alive from one controller to another.
And add this code in your index view.
#if (TempData["message"] != null)
{
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
#TempData["message"] <!--add your message here-->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
}
Then add this script in your index.cshtml.
$(function(){
if($('#myModal').length){
$('#myModal').modal('show');
}
});

Resources