Share tech news, updates, or what's on your mind.

Sign up to Post

Hi Experts,
I want to make the @Html.CountryDropDownList invisible. Please help.
Thanks in advance.

<div class="spacer-15">
        <fieldset id="fieldsetShippingAddress">

            @Html.LabelForRequired(m => Model.Company, T("Organization name").Text)
            @Html.TextBoxFor(m => Model.Company)

            @Html.LabelForRequired(m => Model.Address1, T("Address line 1").Text)
            @Html.TextBoxFor(m => Model.Address1)

            @Html.LabelForRequired(m => Model.Address2, T("Address line 2").Text)
            @Html.TextBoxFor(m => Model.Address2)

            @Html.LabelForRequired(m => Model.City, T("City").Text)
            @Html.TextBoxFor(m => Model.City)

            @Html.LabelForRequired(m => Model.State, T("State/Province").Text)
            <span class="wide-select-ie">
                @*@Html.StateDropDownList("State", Model.State, T("Select one").Text)*@
                @Html.StateDropDownList("StateId", Model.Country, Model.State, T("Select one").Text)
            </span>

            @Html.LabelForRequired(m => Model.PostalCode, T("ZIP/Postal code").Text)
            @Html.TextBoxFor(m => Model.PostalCode)
           
            @Html.LabelForRequired(m => Model.Country, T("Country"))
            @Html.CountryDropDownList("Country", Model.Country, new { onchange = "resetSelect('#State');", @class = "special-dropdown", title = T("Please specify") })
           
        </fieldset>
</div>

public static MvcHtmlString 

Open in new window

0
The Ultimate Tool Kit for Technolgy Solution Provi
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

How to handle Required field validation in Jquery for radiobuttons in asp.net mvc?

Currently, I am handling it in the Model
view \ create.cshtml page

   
<div class="col-sm-3 checkbox-inline">
                        @Html.RadioButtonFor(model => model.IsDateChanged, 1, new { @Id = "IsDateChangedYes" })
                        <label class="hthin" for="IsDateChangedYes">Yes</label>
                        @Html.RadioButtonFor(model => model.IsDateChanged, 0, new { @Id = "IsDateChangedNo" })
                        <label class="hthin" for="IsDateChangedNo">No</label>
                        <span asp-validation-for="IsDateChanged" class="text-danger"></span>
                    </div>

Open in new window



viewmodel \ mymodel.cs

 [Required(ErrorMessage = "Required")]
        [Display(Name = "1. Have there been any changes in the date?")]
        public int? HasDateChanged { get; set; }

Open in new window

0
i have a very simple project to show all of the rental cars in one single company location. But the issue is I want to show all of the rental cars like 50 vehicles on the map.
However, the location is the same. How can I show them on the map? If I just use same location, the car icon will basically overlap each other.
i use c#, mvc, and razor.
0
I start with the following codes with mvc/json/c#
and I just want to know how to get the following items
Or there is easier way to get everything inside of json file. that will be great.


rating
open now
weekday text
viewport
photos height
photos html_attributions


https://developers.google.com/places/web-service/search

WebClient wc = new WebClient();
string jsonStr = wc.DownloadString("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.753,-122.443&radius=10000&type=rv_park&key=AIzaSyCietasdfasdfasdfasdfxzD65Uc19X6DgrJFumdi-nCZYSHjg");
GooglePlacesResponse gpr = (GooglePlacesResponse)JsonConvert.DeserializeObject<GooglePlacesResponse>(jsonStr);
Response.Write(gpr.status + "<br><br>");

Open in new window

0
I need to sort a foreach statement in an MVC website. I've included the code below. I would like to order the results by item.InteractionDate. I believe it is sorting by the Id rather than the InteractionDate. If you need a snippet from the model, I can add that as well.

<table class="table">
        <tr>
            <th>
                Meeting Date
            </th>
            <th>
                Customer
            </th>
            <th>
                Employee
            </th>
            <th>
                Notes
            </th>
            <th>
                Update Meeting
            </th>
        </tr>

        @foreach (var item in Model.Meetings)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.InteractionDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Customer1.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Employee1.FullName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Notes)
                </td>
                <td>
                    @Html.ActionLink("Edit Meeting", "Edit", "Meetings", new { id = Model.Id}, null)
                </td>
            </tr>
        }
    </table>

Open in new window

0
Hi everyone,

I am going to build one cloud based application for multiple customers / businesses, based on that i have few questions.

1) what is the best practice to handle database,  
a) One db for all customers, then what about performance?
b) or is it one db for one customer?

2) let's suppose, if there is power cut (never but due to some reason) or internet down at customer site, in this case what shall be our responsibility?

Thanks
0
How can i easy and securely post data entered in a desktop application (developed in visual studio) to a website (also developed with MVC) for reporting to remote user.

I have developed a desktop application and i want user to periodically post data to a website where others users can see reports.

Sincerely i don't know how to go about this.

Thank you

ANTHONY
0
Is there a good way to allow a MVC app to have a limited number of concurrent logins.  I know how to limit it to one concurrent login, but is is possible to limit it to 3 for instance.
0
https://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/view-without-controller-action-in-mvc/

I followed above help,, and it works to me. However, when I try to add the codes below. it is redirected to notfoundpage which mean is not working. do you know how to fix it?

@{
    ViewBag.Title = "RV Rental Blogs List";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
0
mvc c#, I would like to allow our external users to create webpage. and they will choose anyone of the html templates.
My question is: in mvc, we have manually created controller then add view. How can I handle it in mvc app.?

Thanks
0
Prepare for an Exciting Career in Cybersecurity
Prepare for an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program curriculum features two internationally recognized certifications from the EC-Council at no additional time or cost.

I have below mvc codes and it is pretty common.
My question is: Now I want to add Shared folder called Shared, cut & paste files
from //Home/RenderEventDropDown.cshtml to //Shared/RenderEventDropDown.cshtml.
And then add new controllers called Blog and add new view called Index,
And I want to work exactly same as Home/index/.

Basically, I just want to make RenderEventDropDown.cshtml as shared page so every controller can use it.
is it possible?



@{
    ViewBag.Title = "Motorhome Rental Share";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}


@{

 //Home/Index.cshtml
 Html.RenderAction("RenderEventDropDown");
}


@model List<Domain.Event>    
@for (var i = 0; i < Model.Count; i++)
{      
//Home/RenderEventDropDown.cshtml
<option value="@Html.DisplayFor(x => x[i].id)" style="min-width:600px;">@Html.DisplayFor(x => x[i].name)
    (      
     @Html.DisplayFor(x => x[i].city),
     @Html.DisplayFor(x => x[i].state)
    )
 </option>
}


//HomeController.cs
[OutputCache(Duration = 300, VaryByParam = "none")]
        public PartialViewResult RenderEventDropDown()
        {
            return PartialView(mh.EventList());
        }
0
I am working on MVC. i Select records and clicking on print it generates MS Word document . It works fine on my local machine which has MS word installed. When i moved the code to server it gives me error. I tried installing Interop and also used Office run time dlls. It is telling me to install office. How can i generate Word document WITHOUTinstalling MS office.
0
I am learning MVC 5. I come from a PHP background, so there is a little learning curve for me.

I want to show a form, do something with the results ( probably email it , but that's not the focus of this question ) - and then on a Thank You page, simply have access to the values of the form submitted.

Here is my skeleton project:

HOME CONTROLLER - partial snippet

        //  Show contact us view
        public ActionResult Contact()
        {
            return View();
        }
       
       // Show Thank You Page
      // DO I NEED [HttpPost] HERE???
        public ActionResult ThankYou(ContactModel contactData)
        {
  
           // HOW DO I PASS contactData to my view?
            return View();
        }

Open in new window


ContactModel.cs - I have this file stored in Models/ViewModels folder


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyProject.Models.ViewModels
{
    public class ContactModel
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
}

Open in new window


Contact View

<!DOCTYPE html>
<html>
<body>

<h2>My First MVC Form</h2>

<form action="???????">
  First name:<br>
  <input type="text" name="firstname" >
  <br>
  Last name:<br>
  <input type="text" name="lastname" ">
  <br><br>
  <input type="submit" value="Submit">
</form> 

</body>
</html>

Open in new window


THANK YOU View

<!DOCTYPE html>
<html>
<body>

<h2>Thanks!</h2>

<div>Your First Name is: </div>
<div>Your Last Name is: </div>
 
</body>
</html>

Open in new window



So that's pretty much where I am.  What do I have to do now to get this thing working?

Also, Where do I put the code to say, email the results? I don't need the code, just where does it go? How do I get access to the form data in my views?

THANKS!! I am excited to see this simple form finally work.

OH, and I know I have to include something like "USING ..." on certain views, but I don't know how.

Regards,

John
0
var hour = DateTime.Now.Hour;
            ViewBag.WhenToCall = hour < 12 ? "this Morning" : "this Afternoon";

            return View();

This is on a website. How do I adjust the above so it shows = this evening if between 6pm and 11pm in the evening and how can I improve to show certain messages say on a Saturday or Sunday.
Kind regards.
0
Regular expression validation in mvc class with co.in or .com. I am having my expression as follows
[RegularExpression(@"^\w+([-+.']\w+)*@company-usa.com$", ErrorMessage = "Not a valid email")]

Open in new window

I would like to validate with
@company.in

Open in new window

too like user@company-usa.com or user@company.in
0
.net MVC  or  .net core?

We currently have a web application developed in ASP Classic.
The application is hosted in Microsoft Azure and we use Azure's SQL servers as well as the back-end.

We are still to decide if we move the application and use .net MVC or .net CORE?
I am not too familiar with the pros vs cons.  If there is a website with more information on comparing the two would be great.

I also understand CORE is newer and may not be as mature, do you consider this to be a significant problem?  Moving the system will take about 1 year.
we are using a Bootstrap 'template', AJAX, JSON, XML, etc.

Another thing to consider is that I downloaded Visual Studio in my mac. It would be great if I could check the code there and test the system in the mac computer.
I guess the challenge there will be to connect to our Development Database in Azure.

Any help, guidance, tips and especially comparison would be very useful. I know that sometimes its a matter of taste and seeing both sides of the argument would be very beneficial.
0
Good morning,

Could you please suggest me about the libraries/Nuget packages that can be used to read data from word doc or PDF file.

It would be great help, if you could provide a piece of code using MVC 5.

Thanks
0
exception in chrome
button source code
I am getting an exception
Uncaught Error: cannot call methods on button prior to initialization; attempted to call method 'loading'

when I click a button more than 5 times after that the button stops working
0
I have added areas to my asp.net MVC application, and I have created models inside the area I have created, I'm trying to add the model to the public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, so I can create a migration and update database to get that table added to my DB. but its not recognized. which is the right way of adding models that are located in areas to have them created in the database?
Thanks

PS Im using the code first approach.
0
Cloud Class® Course: Microsoft Windows 7 Basic
LVL 12
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

I am having a devil of a time working out jqgrid using subgrid as a grid for my grid view in MVC. I can get the grid working with out an issue but I seem to be having issues with the json call to get the subgrid to populate. Please let me know if I am doing something incorrectly or if you have any suggestions on improving the code.


JS:

$("#jqGrid").jqGrid({
        url: "/List/GetItems",
        datatype: 'json',
        mtype: 'Get',
        colNames: ['ID', 'Item'],
        colModel: [
            { key: true, hidden: true, name: 'ID', index: 'ItemID' },
            { key: false, name: 'Item', index: 'Item', editable: true }
        ],
        pager: jQuery('#jqControls'),
        rowNum: 20,
        rowList: [10, 20, 30, 40],
        height: '100%',
        viewrecords: true,
        multiselect: false,
        caption: 'Item Records',
        emptyrecords: 'No Records are Available to Display',
        jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            Id: '0',
        },
        autowidth: true,
        multiselect: false,
        subGrid: true,
        subGridRowExpanded: function (subgrid_id, row_id) {
            var sg_tableID = subgrid_id + "_t";
            jQuery("#" + subgrid_id).html("<table id='" + sg_tableID + "' class'scroll'></table>");
            jQuery("#" + sg_tableID).jqGrid({
                url: "/List/getTaskSubList" + 

Open in new window

0
I am trying to populate a ViewModel and I am getting an "Object reference not set to an instance of an object." when trying to populate a List within my main view model. See my two ViewModels and my code to populate them.

As you can see I am building a List of InventoryWorkTypesMSViewModel from a common delimited field of WorkTypes in the InventoryViewModel. Am I doing this wrong? If so what should I do to fix it?

public class InventoryViewModel
    {
        public int InventoryId { get; set; }
        public int ProjectId { get; set; }
        public int Qty { get; set; }
        public bool AuditFlag { get; set; }
        public string UpdatedBy { get; set; }
        public DateTime? UpdatedDt { get; set; }
        public int? ProductNameId { get; set; }
        public string Size { get; set; }
        public string WorkTypes { get; set; }
        public List<InventoryWorkTypesMSViewModel> WorkTypesMS { get; set; }

public class InventoryWorkTypesMSViewModel
    {
        public string WorkType { get; set; }
    }

public List<InventoryViewModel> GetList(int projectId, int? productNameId)
        {
                var model = _db.Inventories
                        .Select(i =>
                              new InventoryViewModel
                              {
                                  InventoryId = i.InventoryId,
                                  ProjectId = i.ProjectId,
                                  Qty = i.Qty,
                                 

Open in new window

0
I want to show DropDown list of Availabe .resx files from Resources folder on viewpage inorder to display selected .resx contents. I displayed the contents but how can i show dropdown of the available .resx files ???
0
0
I'm trying to run a bat file (with parameters) from an MVC controller.  Can somebody please tell me what I'm doing wrong?  When I run this without parameters it works.  When I add parameters, it doesn't.  I get no errors.

This is what it should look like at the command line:
c:
cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
vstest.console.exe "c:\Program Files (x86)\myFolder\SeleniumTest.dll" /TestCaseFilter:"TestCategory=Main Menus"

Open in new window


code snippet from Controller:
steName = Name; //parameter

            Process myProcess = new Process();

            try
            {
                myProcess.StartInfo.UseShellExecute = false;
                myProcess.StartInfo.WorkingDirectory = @"C:\scripts";
                myProcess.StartInfo.FileName = @"C:\scripts\CmdRunTests.bat";
myProcess.StartInfo.Arguments = steName;
//myProcess.StartInfo.Arguments = String.Format("\"{0}\"", steName); //Also tried this line
                myProcess.Start();

bat file:
set steName=%1
@echo off
c:
cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
vstest.console.exe "c:\Program Files (x86)\myFolder\SeleniumTest.dll" /TestCaseFilter:"TestCategory=%1"
pause

Open in new window

0
Hello... new to linq lambda - what is wrong with my query? - I get 'sequence contains no elements' error when there are no providerSpecialties records for the given provider.

This should behave like a left join from the provider entity.

            
             return DBContext.Provider.GroupJoin(DBContext.ProviderSpecialties,
                    p => p.providerId, ps => ps.providerSpecialtyId, (p, ps) => new { Provider = p, ProviderSpecialties = ps.DefaultIfEmpty()})
                    .SelectMany(a => a.ProviderSpecialties
                    .Select(b => new { Provider = a.Provider, ProviderSpecialties = b }))
                    .Where(w => w.ProviderSpecialties.isPrimary == true)
                    .Where (w => w.Provider.providerId == providerId)
                    .Select(m => new ProviderDetail
                    {
                        providerId = m.Provider.providerId,
                        NPI = m.Provider.NPI,
                        licenseNumber = m.Provider.licenseNumber,
                        licenseExpiration = m.Provider.licenseExpiration,
                        licenseStateId = m.Provider.licenseState,
                        licenseStateName = m.Provider.State.abbreviation,
                        networkLevelId = m.Provider.networkLevel,
                        networkLevelName = m.Provider.NetworkLevel1.name,
                        firstName = m.Provider.firstName,
                        lastName = m.Provider.lastName,
       

Open in new window

0

.NET MVC

191

Solutions

209

Contributors

Top Experts In
.NET MVC
<
Monthly
>