how to add fields to contact us page for product tab step by step - nopcommerce

Hi there how do you add fields to the contact us page for nop commerce step by step im new to nop commerce I tried to add a field in ProductContactUs.cshtml but i got a error
Plugins/SevenSpikes.Nop.Plugins.NopQuickTabs/Views/ProductTab/_ProductContactUs.cshtml
the field i added was postaladdress like so
<div class="inputs">
#Html.LabelFor(model => model.PostalAddress)
#Html.TextAreaFor(model => model.PostalAddress, new { #class =
"postaladdress", placeholder = T("ContactUs.PostalAddress.Hint") })
#Html.RequiredHint()
#Html.ValidationMessageFor(model => model.PostalAddress)
</div>
Where else should I add the field. Thanks in advance

Related

Implementing Html.DropDownListFor() in View Only

I am completely new to Asp.Net (junior dev). I'm working on a project that requires a customer to enter data to be stored in a database. When I created the template view for the model, I get a EditorFor() textbox for the customer to enter data. Here's what it looked like:
<div class="form-group">
#Html.LabelFor(model => model.ApplicantState, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
#Html.EditorFor(model => model.ApplicantState, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.ApplicantState, "", new { #class = "text-danger" })
</div>
</div>
This works great, except I want the user to choose from a drop-down list of options rather than enter the data themselves. Here's what I want to do if I were doing the dropdown list with straight HTML:
<div class="form-group">
#Html.LabelFor(model => model.ApplicantState, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<select id="applicantState">
<option disabled selected value> -- Please Select -- </option>
<option value="OH">Ohio</option>
<option value="CA">California</option>
<option value="TX">Texas</option>
</select>
</div>
</div>
I need to get this data to store in the ApplicantState field in the model. The senior developer running this project does NOT want me to add code to the model or controller to do this; he wants me to do the drop-down list in the view only.
Here's what I have...
<div class="form-group">
#Html.LabelFor(model => model.ApplicantState, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
#Html.DropDownListFor(model => model.ApplicantState, new List<SelectListItem> {
new SelectListItem { Value = "" , Text = " -- Please Select -- " },
new SelectListItem { Value = "OH", Text = "Ohio"},
new SelectListItem { Value = "CA", Text = "California"},
new SelectListItem { Value = "TX", Text = "Texas"}
})
</div>
</div>
The code is compiling and I'm not getting any errors. For anyone who's done this before, does this look correct? Will the dropdown list option be stored in the ApplicantState field? I have no confidence in what I've written. I've only ever done a dropdown list from a MVC controller. I'm not yet able to test the code by submitting a fake application. The view is popping up correctly though. Any advice would be appreciated. Thanks!
Because of this:
The senior developer running this project does NOT want me to add code to the model or controller to do this; he wants me to do the drop-down list in the view only.
You need to instantiate at the top of your Razor view this dictionary:
var dictionary = new Dictionary<string, string>
{
{ "OH", "Ohio"},
{ "CA", "California"},
{ "TX", "Texas"}
};
Then replace your razor code with this:
#Html.DropDownListFor(m => m.ApplicantState, dictionary.Select(d => new SelectListItem { Value = d.Key, Text = d.Value }).ToList(), " -- Please Select -- ");
This is clean and should work. After that you need to tell to your co-worker that the dictionary which keep the data should belong to your model and the code should go there.

How to set data-display in razor [duplicate]

This question already has answers here:
Hyphenated html attributes with asp.net mvc
(2 answers)
Closed 6 years ago.
I have a basic password strength indicator.
<input type="password" id="myElement1" size="40" class="left" data-display="myDisplayElement1" />
<div class="left" id="myDisplayElement1"></div>
I have the JS Script which takes care of all the logic. And the data-display div shows the message whether the password is weak or strong. But I want to convert the above code into Razor. Below is what I have till now.
<div class="form-group">
#Html.LabelFor(model => model.NewPassword, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
#Html.EditorFor(model => model.NewPassword, new { htmlAttributes = new { #class = "form-control", id = "myElement1" } })
<div class="left" id="myDisplayElement1"></div>
#Html.ValidationMessageFor(model => model.NewPassword, "", new { #class = "text-danger" })
</div>
</div>
Question: Everything is working fine but I am not able to put data-display attribute in razor. Where do I need to place it. But as the data-display is not set, I am not able to display the user its password strength as the div.
I want to be able to do something like below
#Html.EditorFor(model => model.NewPassword, new { htmlAttributes = new { #class = "form-control", id = "myElement1" , data-display = "myDisplayElement1"} })
But data-display gives me error.
Error
Cannot resolve symbol data the error comes at the place where I have added data-display.
Hyphenation is not valid within an anonymous object. However, knowing that it would be necessary at times to add attributes with hyphenation, the Razor helpers will auto replace underscores with hyphens in attribute names. As a result, you can accomplish what you need by using data_display rather than data-display.

Field positioning in mvc

I am trying to position these text fields next to each other and have them in the following format:
(______) _____ - _____
My main problem is getting them to be next to each other. Does anybody have any suggestions on what I should do?
Here is the code I have so far:
<label style="margin: 5px" id="lblPhoneNumber">Phone Number (optional)</label>
<p>
#Html.ValidationMessageFor(model => model.Pharmacy.PhoneNumber)
#Html.TextBoxFor(model => model.Pharmacy.AreaCode, new { style="width:3em", maxlength=3})
#Html.TextBoxFor(model => model.Pharmacy.PhoneNumberFirstThree, new { style="width:3em", maxlength = 3 })
#Html.TextBoxFor(model => model.Pharmacy.PhoneNumberLastFour, new { style="width:4em", maxlength = 4 })
</p>
It will be something like. You need to do it for all three textboxes:
#Html.TextBox("Something", #Model.text, new {style = "display: inline-block;float:left"})

MVC5/razor - Login Password asterisks appearing on Change Password form

On my Change Password form I have asterisks appearing in the New Password field. I assume they are appearing as a leftover from the password field from the Login Form?
Change Password form (partial):
<div class="form-group">
#Html.LabelFor(m => m.Password, new { #class = "col-md-3 control-label" })
<div class="col-md-9">
#Html.PasswordFor(m => m.Password, new { #class = "form-control" })
#Html.ValidationMessageFor(m => m.Password)
</div>
</div>
<div class="form-group">
#Html.LabelFor(m => m.ConfirmPassword, new { #class = "col-md-3 control-label" })
<div class="col-md-3">
#Html.PasswordFor(m => m.ConfirmPassword, new { #class = "form-control" })
#Html.ValidationMessageFor(m => m.ConfirmPassword)
</div>
</div>
This behavior is probably browser-related due to a cookie from saving the password on login. I'm just wondering if there is anyway to overcome this without renaming the Password field?
#Html.PasswordFor (and all of the other xxxFor HtmlHelpers) will fill in the input field with whatever value the model has for the property when the page is rendered. In this case, Model.Password must already have a value, perhaps from when you fetched the user from the database. Note, if you are storing the user's password somewhere in plain text, this is bad practice.
Before the call to View in your Controller, clear out the Password property.
If that doesn't work and you've confirmed the Password property of the Model is empty when the page loads, then perhaps it is some browser autocompletion as you say. You can try adding autocomplete = "off" attribute to the input element.

Field password returned empty to view in edit mode

I've MVC5 application and in the create view i have user and password fields.
I put values in the user and password field and when I enter to edit mode i see just the user value in the text box
and the password field is empty,why?
when I debug the code I see that in the end of the edit ( return View(UserPass); ) i got the object with the values and than it call to the view(razor) and I dont see the value in the pass text box ...
Any idea why the user is exist and password not?
I just want it to be field with asterisks in the edit mode...
In the edit and the create view I use:
<div class="form-group">
#Html.LabelFor(model => model.Password, new { #class = "control-label col-md-2" })
<div class="col-md-10">
#Html.PasswordFor(model => model.Password)
#Html.ValidationMessageFor(model => model.Password)
</div>
</div>
Passwords are not prepopulated to prevent accidential submits and not to have un encrypted passwords.
check below link.
ASP.Net MVC3 Html.PasswordFor does not populate
Use this:
#Html.PasswordFor(model => model.Password,new{#Value=Model.Password})
Notice that Value:v should be uppercase
Rendering the value of a password into the html source is a huge security risk. Its preventing you from leaking your passwords. Otherwise someone could view the page source and see:
<input type="password" value="password123" />
I would recommend doing the following:
#Html.PasswordFor(model => model.Password, new { placeholder = "********" })
This will put some 'visual' asterisks in the textbox which will disappear when the user starts entering an actual value. Its not supported by all browsers, but its something.

Resources