[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

.NET MVC

223

Solutions

233

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

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

Sign up to Post

Hello,
I am trying to build an app in ASP.NET MVC amd get this error:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /Views/Random.cshtml

Open in new window


Any suggestions?

Thanks
0
SD-WAN: Making It Work for You
SD-WAN: Making It Work for You

As bandwidth requirements and Internet costs grow, businesses naturally want to manage budgets by reducing reliance on their most expensive connection types. Learn more about how to make SD-WAN work for your business in our on-demand webinar!

Hi Experts,
I have a text box with ID CustomerEmailAddress and on blur it validates the email and display a warning message at the top. If there is a warning message I want to change the corder color of the text box to red. I added some code(In bold). But still it is not working.  Any suggestions?
 jQuery(document).ready(function () {
        jQuery("#CustomerEmailAddress").blur(function () {
            jQuery.ajax({
                type: "POST",
                url: '@Url.Action("BusinessDomain", "Marketing")',
                data: '{email: "' + jQuery("#CustomerEmailAddress").val() + '" }',
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {
                    if (response == true) {
                        var CustomerEmailAddress = jQuery("#CustomerEmailAddress").val();
                        CustomerEmailAddress = jQuery.trim(CustomerEmailAddress);
                        var DomainName = CustomerEmailAddress.split("@@")[1];
                        var msg1= "Please provide an email address that has a business domain. Email domains at ";
                        var msg2 = " require further review by the program and will cause a delay in your application being approved.";
                        var msg = msg1 + DomainName + msg2;
                        jQuery("div.validation-summary-warning", "#frmSubmitCustomerInformation").text(msg).show();
                       

Open in new window

0
Hi Experts,
I have this to display a message dynamically onblur event of a textbox.
jQuery("#formEnroll").prepend("<div class='validation-summary-warning'>" + msg + "</div>") 

Open in new window


But it keeps adding the div every time when the focus is lost. So how can I check and display  the div only once. only if the div is not exists. It is really urgent!

Thanks in advance.
0
Hi all

I would like to remotely connect to ms-sql database through port 1433 connection. which service provider/hosting service provider for ASP.NET that can help me get this.

I am having a desktop application. I would want this application to remotely write data to a website database.  

Regards

Anthony
0
In web forms, I know how to create master page.  Is it possible to create a master page in ASP. Net core MVC? Please show an example and link.
0
I am using ASP.NET MVC 5 with entity framework version 6. I have the PagedList.MVC nuget package installed. I get the error listed below when attempting to sort in my Index view. I'm sure it is something really simple that I am overlooking.

The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.'

Controller Code listed below:

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using ITRA.Models;
using PagedList;
using PagedList.Mvc;

namespace ITRA.Controllers
{
    public class SSP_ControlController : Controller
    {
        private RiskAssessmentEntities2 db = new RiskAssessmentEntities2();

        // GET: SSP_Control
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int? page)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.NISTIDSortParm = String.IsNullOrEmpty(sortOrder) ? "NISTID_asc" : "";
            ViewBag.TitleSortParm = String.IsNullOrEmpty(sortOrder) ? "Title_asc" : "";
            ViewBag.WorksheetStatementSortParm = String.IsNullOrEmpty(sortOrder) ? "WorksheetStatement_asc" : "";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            

Open in new window

0
I wrote this code using ASP.NET webforms and would like to move it to an MVC solution.  What should go in the controller and what should go in the model.  How do I pass information from one to the other?

            string ErrorMessage="";

            //check name lengths are OK.
            if (txtBorrowerFullName.Text.Length == 0)
            {
                ErrorMessage = "Borrower fullname empty. ";
            }
            if (txtBorrowerFullName.Text.Length > 54)
            {
                ErrorMessage = ErrorMessage + "Borrower fullname exceeds 90 characters. ";
            }

            if (txtBorrowerName2.Text.Length == 0)
            {
                ErrorMessage = "Borrower name empty. ";
            }
            if (txtBorrowerName2.Text.Length >19)
            {
                ErrorMessage = ErrorMessage + "Borrower name exceeds 19 characters. ";
            }
            if (txtBorrowerShortName.Text.Length == 0)
            {
                ErrorMessage = "Borrower shortname empty. ";
            }
            if (ErrorMessage == string.Empty)
            {
using (SqlConnection sqlCon = new SqlConnection())
                {
                    using (SqlCommand sqlcmd = new SqlCommand())
                    {
                       ConnectionString = ConfigurationManager.ConnectionStrings["UK1SDI2DSConnectionString"].ConnectionString;
                        sqlcmd.Connection = sqlCon;
                        sqlCon.ConnectionString = 

Open in new window

0
I have the following method below and I'm having a hard time understanding what does the following notation mean... The following code is reading from a table and converting it to a variable just not sure why the 9?

requiredFields[9] == 'T',  why a 9?

public static GeneralSetupProgramJobParameter GetProgramJobParameters(
            GeneralSetupProgramJobParameter item,
            string reqdfields,
            string prodparam,
            string chngparam,
            string estutilfld,
            bool defaultStatus0For2ndPrgm
            )
        {
                var requiredFields = reqdfields.ToCharArray();
                var productionDefaults = prodparam.ToCharArray();
                var changeParams = chngparam.ToCharArray();
                var estUtilFields = estutilfld.ToCharArray();

                item.DefaultToStatus0For2ndProgram = defaultStatus0For2ndPrgm;

                item.ProgramJobRequiredFields = new ProgramJobRequiredFields
                {
                    IsRequiredDateSold = requiredFields[9] == 'T',
                    IsRequiredSalesPerson = requiredFields[11] == 'T',
                    IsRequiredSource = requiredFields[10] == 'T',
                    IsRequiredSize = requiredFields[16] == 'T',
                    IsRequiredRoute = requiredFields[14] == 'T',
                    IsRequiredCancelDate = requiredFields[12] == 'T',
                    IsRequiredCancelReason = requiredFields[13] == 'T',
                    

Open in new window

0
Hi Experts,
I am working on a MVC.Net application with C#.Net code-behind.

I am using an Array in one of my views.
I am able to populate my array just fine, but I need to do the following once I have populated my array:
1. Group by the following fields: order, item, description
2. Sort by the following fields: order, item, description

I have included my javascript code below.  
Please show me how to do my grouping and sorting of my javascript array.

var claimsHeader = new Array(); 



function onDataBoundHeader(arg) {
	var dataItemsHeader = arg.sender.dataSource.view();

        for (var j = 0; j < dataItemsHeader.length; j++) {
            var order = dataItemsHeader[j].get("Item");
            var item = dataItemsHeader[j].get("Market");
            var description = dataItemsHeader[j].get("Description");
            
            var claims = new Array(order, item, description);
            claimsHeader.push(claims);
        }
}

Open in new window


Thank you in advance,
mrotor
1
I have created a GeneralSetupCompanyView Model inside my GetViewModel but I'm getting the following error when I assign my property CountryOption to the value CountryOptions = GetViewModelCountryOptions(vm.SelectedCountry).  
This GeneralSetupCompanyView is in a different namespace than the namespace ServiceAssistant.Areas.Parameters.Controllers.

My question is do I need to move my Service.Assistant.Model.Service.Picker.Item to the namespace where my GeneralSetupCompanyreside  or how should I correct this line of code:
CountryOptions = GetViewModelCountryOptions(vm.SelectedCountry),

Cannot implicitly convert type "System.Collection.Generic.List<Service.Assistant.Model.Service.Picker.Item>'to 'System.Collections.Generic.List<Systems.Models.SelectPicker.Item>'

namespace ServiceAssistant.Areas.Parameters.Controllers
{
    public class CompanyGeneralSetupController : BaseController
    {
        // GET: Parameters/CompanyGeneralSetup
        public ActionResult Index()
        {
            var employee = LoggedInUser;
            canView = null;
            if (!canView)
            {
                return RedirectToAction("Index", "Parameters", new { area = "Parameters" });
            }

            var viewModel = GetViewModel(employee);
            return View(viewModel);
        }

        private GeneralSetupCompanyViewModel GetViewModel(Employee employee)
        {
          
            var parameters = 

Open in new window

0
Big Business Goals? Which KPIs Will Help You
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

I running into a pittfall I have an action that I'm trying to refactor so that it call a service that will populate a model that I created.

 My only issue is that I have a bunch of method that I'm not sure if they should belong to the service or I just should leave them on the controller level. My assumption is to not implement these method in my new service that I will create.  The methods that I'm referring to are as follow:
 PopulateSecurityParameters(parameters, viewModel);
  PopulateCancelSoldParameters(parameters, viewModel);
  PopulateCallLogParameters(parameters, viewModel);

[  private ViewModel GetViewModel(Employee employee)
        {
            var viewModel = new ViewModel();
            var parameters = ParameterConfigurationService.GetParameters();

            viewModel.CommonSmtpSettingsOptions = GetCommonSmtpSettingsOptions();

            viewModel.StatusInfoList = GetStatusInfoList(parameters);

            PopulateSecurityParameters(parameters, viewModel);
            PopulateCancelSoldParameters(parameters, viewModel);
            PopulateCallLogParameters(parameters, viewModel);
            PopulateGeneralParameters(parameters, viewModel);
            PopulateAppointmentCallParameters(parameters, viewModel);
            PopulateSmtpParameters(viewModel);

            viewModel.CountryOptions = GetViewModelCountryOptions(viewModel.SelectedCountry);
            viewModel.QuickNoteOptions = 

Open in new window

0
I would like to get some feedback on what is the best way to create a model from this screen representation that I have attached bellow. I created a class GeneralSetupCompanyParame and I'm not sure how I should declare each property that I have circled in yellow in my screenShot. The one for the English,Spanish, French Description...

I'm just looking for the best representation. I started creating my company class, I'm just missing how I will set my property for the English,Spanish and French Description.

 public class GeneralSetupCompanyParameters
    {

         public class SMTPSettings
        {
            public string CommonSMTPSettings { get; set; }
            public string SMTPServer { get; set; }
            public int SMTPPort { get; set; }
        }
        
        public string CountryName { get; set; }

        public string ServiceYear { get; set; }
        public string QuickNote { get; set; }
        public bool AllowFutureSaleDates { get; set; }
        public bool ForcePWComplexity { get; set; }
        public bool AppointmentNotification { get; set; }
        public bool LimitPastSaleDates { get; set; }
        public int LimitPastSaleDatesDay { get; set; }
        public bool ForcePeriodicPWChanges { get; set; }
        public bool LockCallLogEntries { get; set; }
        public string EveryDay { get; set; }
        public bool LimitPastCancelDates { get; set; }
        public string LimitPasCancelDatesDays { get; set; }
        public bool 

Open in new window

0
Hi All,
Am following  this link to create we signature. It is working for one display and one editor. How to have 2 display and 2 editors respectively.
https://www.thewebflash.com/using-signature-pad-with-asp-net-mvc/

please find the screen shot. i need to capture WLM signature and editor image.


Kind regards,
Pooja
Capture.PNG
shtml.txt
signature_pad.js
signature_pad.min.js
SignaturePad-display-.cshtml
SignaturePad.cshtml
0
I need some examples of how to do advanced grouping and formatting using GemBox and C#.
We use MVC

Thank You!
0
Hi Expert,
I'm start learning  ASP.net MVC ,But I understand there is ASP.net core MVC, Which one you guys think i have to study
0
I need to create dynamically  image tag in a Razor Page. I'm having problem creating that. I 'm not getting the right format.  When i inspect the element
The tag looks like this

<img class="" alt="" src="http://localhost:53339/images/ticket.PNG?mw=100"
 srcset="http://localhost:53339/images/ticket.PNG?mw=500500w,
 http://localhost:53339/images/ticket.PNG?mw=600600w,
 http://localhost:53339/images/ticket.PNG?mw=700700w," 
 sizes="(min-width:300px)100px,(min-width:400px)200px," 100vw="">

Open in new window


The tag should look like this

src="http://localhost:53339/images/ticket.PNG?mw=320" 
srcset=
"http://localhost:53339/images/ticket.PNG?mw=600 600w,	
http://localhost:53339/images/ticket.PNG?mw=200 800w,	
http://localhost:53339/images/ticket.PNG?mw=600 1600w"
sizes="(min-width: 320px)  280px,
            (min-width: 480px)  440px, 100vw"

Open in new window


There should be space between 600600w  should look like this 600 600w
There should be space between (min-width:300px)100px  should look like this sizes="(min-width: 320px)  (space here)280px

This 100vw="" should be like 100vw"

 Here is sample code

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

namespace MVCTEST.Controllers
{
    public class DefaultController : Controller
    {
        // GET: Default

        public ActionResult Index()
        {
            int[] intArrayInput = {100, 200};
            int[] intArrayInput2 = {300,400};

 

Open in new window

0
Hi All,
Advance thanks
In cshtml i want something like image at the left  . Heading and sub text should within image height . Heading in bold and sub heading in normal text

---------------------------------------------------------------------------------------------------------------
         -
  img -                                            Title at the center
          -
          -                                                    some text(in middle of title text)
--------------------------------------------------------------------------------------------------------------------------

<div>

            <img class="img-valign" src="~/images/mainPageLogo_1.jpg" style="width:60px;height:60px;" alt="" />
            <span class="text2" style="text-align:center">some text2</span>
            <span class="text2">text2</span>

      </div>

Kind regards,
Pooja
0
Hi All,
Advance thanks!
Using C#, mvc , bootstrap.
I need a help to set multiple line attribute on text box.

@Html.TextBoxFor(m => m.Other, new { id = "txtOther", @class = "textBoxmulti" })


.textBoxmulti {
            border: 1px solid #e2e2e2;
            background: #fff;
            color: #333;
            font-size: 1.0em;
            margin: 5px 0 6px 0;
            padding: 5px;
            width: 800px;
            height: 40px;
      }


Model
======
            [Display(Name = "Other Changes")]
            [DataType(DataType.MultilineText)]
            public string Other { get; set; }

Still not accepting new line.

Kind regards,
Pooja
0
Hi,

I'm looking on expert suggestion. I found several options, but maybe someone will guide me for proper solutions.

I'm building severals web apps, and each apps, need a Help. I don't want spending time building an engine / framework for my help. Do you know an API / System I can integrate with easily with my web apps. Here's my requirements.....

  • Search, I want only to add a search box in my apps and this will call an API to search the "Online" system
  • Easy Interface for Creating Article / Help Page an Editor basically (can be a look and feel like WorkPress)
  • Possibility to add Image, Documents, Large Files (Video)
  • Online / Hosted preferably Offline option can also be consider
  • If possible, Security UserName / Password for users to access the Help (Not mandatory)

Some Ticketing System (ZenDesk, Zoho, ...) offert similar feature but it's not a full framework for help...

Anything exist on the market ?.... an Online Wikipedia with a Search API....

Free or Not, I want to check the options.

Thanks for sharing.
0
Fundamentals of JavaScript
LVL 12
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I ran across an error I am having some trouble with and was hoping yall could help. I am using an jqgrid in MVC. I have no issues with the create or delete functions but for some reason I am passing a id value of 0 for all rows for my edit function. I am hoping I am overlooking a typo:

grid:
$('#TaskGrid').jqGrid({
            url: "/Users/getUsers",
            datatype: 'json',
            mtype: 'Get',
            colNames: ['UID', 'SID', 'DisplayName', 'isAdmin'],
            colModel: [
                { key: true, hidden: true, name: 'UID', index: 'UID', editable: false },
                { key: false, name: 'ID', index: 'ID', editable: true },
                { key: false, name: 'DisplayName', index: 'DisplayName', editable: true },
                { key: false, name: 'isAdmin', index: 'isAdmin', editable: true, filter: true }
            ],
            height: '100%',
            rowNum: 10,
            pager: jQuery('#jqControls'),
            viewrecords: true,
            caption: 'User Management',
            emptyrecords: 'No Records Found',
            jsonReader: {
                root: "rows",
                page: "page",
                total: "total",
                records: "records",
                repeatitems: false,
                Id: "0"
            },
            autowidth: true

Open in new window


jqgrid edit function:
{
                zIndex: 100,
                url: '/Users/EditUser',
                closeOnEscape: true,
                closeAfterEdit: true,
                recreateForm: true,
                afterComplete: function (response) {
                    if (response.responseText) {
                        alert(response.responseText);
                    }
                }
            }

Open in new window


edit function:
public string EditUser(User Model)
        {
            string msg;
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(Model).State = EntityState.Modified;
                    db.SaveChanges();
                    msg = "Save Successfully";
                }
                else
                {
                    msg = "Validation of data not successful";
                }
            }
            catch (Exception ex)
            {
                msg = "Error: " + ex.Message;
            }
            return msg;
        }

Open in new window


when i debug the object being passed to the controler shows the correct data the the line i am editing, id, displayname, isAdmin but the primary key for the db, uid is always 0.

Thank you in advance for any help.
0
Just have mvc app has esign feature and hope to add two way auth meaning the signer has to enter code to continue esign.

I use jsignature and it is working fine.

If you know any sources I can read to get start. Let me know
0
Hi All,
Advance thanks!
Am using VS 2017 ,MVC, C#.
My view has controls and button1. When i click button1 , show word document template with respective controls values filled in appropriate location in word doc. Can you give me some idea or links to follow to achieve this task step by step so that it is easy to follow and adapt on my solution.


Kind regards,
Pooja
0
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
Hi Experts.

Have tried googling "can mvc5 coexists with razor"; but didn't find anything helpful.

So, in our MVCr project we created a folder called "Pages" and added a razor3 file called "Test.cshtml".
MVC5 project with a Razor3 page The project builds and when trying to navigate to the razor page:

resource not found
any ideas?

TIA!
0
How to fetch HTML Input Id in code behind ASP.Net MVC ? Either on Controller or on Model ?

 view / .cshtml 

<button type="submit" id="previewButton" >Preview</button>

JQuery : - This will not be in use.

$("button").click(function ()
    {
        var btn = this.id;
          alert(btn);
   }

In Controller :

[HttpPost]
        public ActionResult New(MyViewModel viewModel, string clickedButton)
        {
            
            var vm = clickedButton;
            return View(vm);
        }

- MyViewModel
 public string clickedButton { get; set; }

Open in new window

0

.NET MVC

223

Solutions

233

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

Top Experts In
.NET MVC
<
Monthly
>