Its shows some unwanted autocomplete suggestions.
I think those suggestions coming from UserName text field.
But I do not find any reason for those suggestions.
Model Code:
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
[Required(ErrorMessage = "Birth Date is Reqired")]
[DataType(DataType.DateTime)]
[Display(Name = "Birth Date")]
public DateTime BirthDate { get; set; }
Razor View:
<div class="container jumbotron" style="background-color:whitesmoke">
<div class="row">
<div class="col-md-4" style="margin-left: 400px; margin-top:30px">
<section id="loginForm">
#Html.ValidationSummary(true)
#using (Html.BeginForm("Registration", "SignUp", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<div class="form-group">
#Html.LabelFor(m => m.FirstName)
#Html.TextBoxFor(m => m.FirstName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.FirstName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.LastName)
#Html.TextBoxFor(m => m.LastName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.LastName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.UserName)
#Html.TextBoxFor(m => m.UserName, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.UserName)
</div>
<div class="form-group">
#Html.LabelFor(m => m.EmailAddress)
#Html.TextBoxFor(m => m.EmailAddress, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.EmailAddress)
</div>
<div class="form-group">
#Html.LabelFor(m => m.BirthDate)
<input class="form-control" value="yyyy-MM-dd" name="BirthDate" type="text" id="BirthDate" autocomplete="off">
#Html.ValidationMessageFor(m => m.BirthDate)
</div>
<div class="form-group">
#Html.LabelFor(m => m.PassWord)
#Html.PasswordFor(m => m.PassWord, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.PassWord)
</div>
<div class="form-group">
#Html.LabelFor(m => m.VerifyPassWord)
#Html.PasswordFor(m => m.VerifyPassWord, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.VerifyPassWord)
</div>
<div class="form-group">
#Html.LabelFor(m => m.VersityId)
#Html.TextBoxFor(m => m.VersityId, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.VersityId)
</div>
<div class="form-group">
#Html.LabelFor(m => m.PhoneNumber)
#Html.TextBoxFor(m => m.PhoneNumber, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.PhoneNumber)
</div>
<div class="form-group">
#Html.LabelFor(m => m.Address)
#Html.TextAreaFor(m => m.Address, new {#class = "form-control"})
#Html.ValidationMessageFor(m => m.Address)
</div>
<div class="form-group">
<input id="ImageUpload" type="file" name="ImageUpload" />
</div>
<button type="submit" class="btn btn-primary">Save</button>
}
<p>
#Html.ActionLink("Already Have an Account", "LogIn")
</p>
</section>
</div>
</div>
Problem view (Image) :
Problem indicate by red circle
I don't want this kinds of suggestions.
Please help me for get ride of this problem.
Thanks a lot advance
From this site, maybe this is your issue, the autocomplete should do the trick, but if your whole page is rendering over XHTML, then you will need something like this.
https://css-tricks.com/snippets/html/autocomplete-off/
.autocomplete=”off” is not valid markup with XHTML Transitional, which is a common DOCTYPE. Use this to keep a vaild markup
if (document.getElementsByTagName) {
var inputElements = document.getElementsByTagName(“input”);
for (i=0; inputElements[i]; i++) {
if (inputElements[i].className && (inputElements[i].className.indexOf(“disableAutoComplete”) != -1)) {
inputElements[i].setAttribute(“autocomplete”,”off”);
}
}
}
Related
I have an Html.DropDownListFor with BootStrap that is not left justifying like the Html.TextBoxFor in my form. I've tried both the "pull-left" and "text-left" with no luck. When I look at page with the Developer Tools there doesn't look to be anything that I can see causing a problem.
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Submitter Information</h3>
</div>
<div class="panel-body">
<div class="row form-group">
#Html.LabelFor(m => m.EmployeeId, new { #class = "col-md-4 control-label text-right" })
#Html.TextBoxFor(m => m.EmployeeId, new { #class = "col-md-8 form-control", #readonly = "true" })
</div>
<div class="row form-group">
#Html.LabelFor(m => m.EmployeeName, new { #class = "col-md-4 control-label text-right" })
#Html.TextBoxFor(m => m.EmployeeName, new { #class = "col-md-8 form-control", autofocus = true, #placeholder = "Employee Name" })
</div>
<div class="row form-group">
#Html.LabelFor(m => m.EmployeeEmail, new { #class = "col-md-4 control-label text-right" })
#Html.TextBoxFor(m => m.EmployeeEmail, new { #class = "col-md-8 form-control", #placeholder = "Email Address" })
</div>
<div class="row form-group">
#Html.LabelFor(m => m.SelectedEmployeeCo, new { #class = "col-md-4 control-label text-right" })
<div class="col-md-8 pull-left">
#Html.DropDownListFor(x => x.SelectedEmployeeCo,
new SelectList(Model.Companies, "Co", "Name"),
"-- Select Company --",
new {#class = "form-control text-left" })
</div>
</div>
</div>
</div>
I changed some things around and this should have been obivious to me since I was doing the same thing for the other TextBoxFor. I ended up moving the column class into the CSS directly on the DropDownListFor instead of in a separate div. I would have thought it would render the same but it doesn't. So, the point here is to be consistent. Either wrap each control in a div with the column CSS or apply the CSS directly on the control.
This is how I fixed it.
<div class="row form-group">
#Html.LabelFor(m => m.SelectedEmployeeCo, new { #class = "col-md-4 control-label text-right" })
#Html.DropDownListFor(x => x.SelectedEmployeeCo,
new SelectList(Model.Companies, "Co", "Name"),
"-- Select Company --",
new { #class = "col-md-8 form-control pull-left" })
</div>
I'm having some issues working with bootstrap. I'm a little confused right now. I need to add a form on the right side of a photo in Asp.net MVC. I have a render body on my main page and then in the other view I have this bootstrap code:
#using (Html.BeginForm("EditarUtilizador", "Account", null, FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
System.Diagnostics.Debug.WriteLine(#Html.DisplayFor(modelItem => modelItem.ImagePath));
<div class="form-horizontal">
<h4>Editar Perfil Pessoal</h4>
<hr />
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<fieldset class="col-md-3">
#if (Model.ImagePath != null)
{
<img src="~/Images/#Html.DisplayFor(modelItem => modelItem.ImagePath)" width="150" height="150" />
}
else
{
<img src="~/StaticImages/default-user-image.png" width="150" height="150" />
}
<div class="editor-field">
<input id="ImagePath" title="Upload a product image"
type="file" name="file" />
</div>
</fieldset>
<div class="form-group" >
#Html.LabelFor(m => m.Utilizador, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.DisplayFor(m => m.Utilizador, new { #class = "form-control"})
#Html.ValidationMessageFor(model => model.Utilizador, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.Password, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.EditorFor(m => m.Password, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.NovaPassword, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.EditorFor(m => m.NovaPassword, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.Email, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.DisplayFor(m => m.Email, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.Email, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.Telemóvel, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.EditorFor(m => m.Telemóvel, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.Telemóvel, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.DataNascimento, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.EditorFor(m => m.DataNascimento, new { #class = "form-control", type = "date", })
#Html.ValidationMessageFor(model => model.DataNascimento, "", new { #class = "text-danger" })
</div>
What I have at the moment is this:
I want to form to appear on the right, but in my case it appears below the image.
Because <div> elements are block-level, they will stack on top of one another by default. Alter the CSS to get what you desire.
Using Bootstrap Grid Mechanism
You can align content in the following manner
#Html.BeginForm(){
<div class="row">
<div class="col-md-8">
Add the input fields in this column
</div>
<div class="col-md-4">
Add the image portion here
</div>
</div>
}
The maximum value of column in Bootrap grid is 12, you can divide this value into individual columns like I did. You can tweak the col-md-* values according to your preference.
You can learn more about the bootstrap Grid in the following link.
https://getbootstrap.com/examples/grid/
I want to encrypt the user password before I submit it to the server in MVC 5.
I was thinking if I should use RSA to encrypt/decrypt it or their is a better way prehaps a html helper in MVC 5 for that?
I have this login form:
#model LoginViewModel
<div class="row">
<div class="col-md-8">
<section id="loginForm">
#using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-horizontal", role = "form" }))
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<div class="form-group">
#Html.LabelFor(m => m.Email, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.TextBoxFor(m => m.Email, new { #class = "form-control", id = "Email", Value = "foo#bar.com" })
#Html.ValidationMessageFor(m => m.Email, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.Password, new { #class = "col-md-2 control-label" })
<div class="col-md-10">
#Html.PasswordFor(m => m.Password, new { #class = "form-control", id = "Password", Value = "baz" })
#Html.ValidationMessageFor(m => m.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Log in" class="btn btn-default" />
</div>
</div>
}
</section>
</div>
</div>
#section Scripts {
#Scripts.Render("~/bundles/jqueryval")
}
I've got display problem when using http://eternicode.github.io/bootstrap-datepicker in Bootstrap 3.
How to get datepicker in this picture?
I'm using MVC 5 with auto generated views
Create.cshtml
<div class="form-group">
#Html.LabelFor(model => model.TerminateDate, new { #class = "control-label col-md-2" })
<div class="col-md-10">
<div class="input-group date" id="dp3">
#Html.EditorFor(model => model.TerminateDate, new { htmlAttributes = new { #class = "form-control datepicker", #readonly = "readonly" } })
<span class="btn btn-default input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
#Html.ValidationMessageFor(model => model.TerminateDate)
</div>
</div>
</div>
UPDATE:
Now it looks like better but a little long, how to set the length?
<div class="form-group">
#Html.LabelFor(model => model.TerminateDate, new { #class = "control-label col-md-2" })
<div class="col-md-4">
<div class="input-group date">
#Html.EditorFor(model => model.TerminateDate, new { htmlAttributes = new { #class = "form-control date", #readonly = "readonly" } })
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
#Html.ValidationMessageFor(model => model.TerminateDate)
</div>
</div>
</div>
Hope this helps. I just added some class and change some tag. It will look like this
<div class="form-group">
#Html.LabelFor(model => model.TerminateDate, new { #class = "control-label col-md-2" })
<div class="input-group col-md-10">
<input type="text" class="form-control input-group date" id="dp3">
#Html.EditorFor(model => model.TerminateDate, new { htmlAttributes = new { #class = "form-control datepicker", #readonly = "readonly" } })
<span class="btn btn-default input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
#Html.ValidationMessageFor(model => model.TerminateDate)
</div>
</div>
Update:Take a look at the "Column sizing" subsection here
Try to follow this format:
<div id="datetimepicker1" class="input-append date">
<input data-format="dd/MM/yyyy hh:mm:ss" type="text"></input>
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar">
</i>
</span>
</div>
The default site.css created when you make a new project has a max-width set on the input element:
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
Remove or comment this out and your col-md-10 will work perfect.
In my Asp mvc project I want to add company to database without refreshing the page.
How can I do it with ajax. I want to submit data and return to the same page without refresh.
this is a part of my code
#using (Html.BeginForm("Create", "Company", FormMethod.Post, new { enctype =
"multipart/form-data" }))
{
#Html.ValidationSummary(true)
<fieldset>
<div class="editor-label">
#Html.LabelFor(model => model.nom_company)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.nom_company)
#Html.ValidationMessageFor(model => model.nom_company)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.desc_company)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.desc_company)
#Html.ValidationMessageFor(model => model.desc_company)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.datedebut_company)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.datedebut_company)
#Html.ValidationMessageFor(model => model.datedebut_company)
</div>
<div class="editor-label">
#Html.LabelFor(model => model.datefin_company)
</div>
<div class="editor-field">
#Html.EditorFor(model => model.datefin_company)
#Html.ValidationMessageFor(model => model.datefin_company)
</div>
<p>
<input type="file" name="file" />
<input type="submit" value="Create" />
</p>
</fieldset>
}
Any help please