.NET MVC

402

Solutions

299

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

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 have very rare website that allow owner and renter to get motorhome similar to turo but now I am looking for insurance companies that partner with us so we can get insurance for each rental

I hope to know what I can do to get start it.
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 am very new on using json and I want to have very simple code in c# to request docsign signature with json format.

can you show me ? thanks

I have most of the set up like api key and etc already

thanks
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
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
i just take over a mvc with entity framework project and the developer is gone.
Now I added a column in the database table, and how can i refresh the entity framework so I can continue to code with linq...?

I am not expert with any projects that using entity framework. hope you can help out.

Thanks
0
i have mvc web form and create  localStorage.getItem("member-id") after the login/password is checked and valided.
how can i drop  localStorage.getItem("member-id") value to mvc controller?


public PartialViewResult RenderDashboardLeadList()
{
    string currentStage = Request.QueryString["Stage"];
    if (currentStage == null)
    {
        currentStage = "Open";
    }
    return PartialView(mh.EventLeadList(currentStage,"localstorage?"));
}

Open in new window

0
I need some helps to learn how to switch src from embed html. When alert("Success:" + result); I want to switch documentlink's src to http://www.google.com.
so i try to use document.getelementid("").src = 'http://www.google.com' and it does not seem working. and I got one help in the past using localstorage but
it does not work with the codes. So I hope to get some helps.

Thanks,                
@{ 
    string documentLink = Request.QueryString["link"].ToString();
    string hreflink = documentLink;     
    Uri uri = new Uri(hreflink);
    var filename = uri.Segments.Last();        
    string documentId = Request.QueryString["documentId"];
    string quoteId = Request.Url.Segments[3];
    string signingStage = "Signing";
}


<script>
       $(document).ready(function () {
               saveButton.addEventListener('click', function (event) {
               var dataPng = pad.toDataURL('image/png');
               //alert(dataPng);
               $.ajax({
                   url: "/Home/CreateSignatureOnDocument",
                   datatype: "json",
                   data:
                   {
                       'quoteId': '@quoteId',
                       'documentId': '@documentId',
                       'fullname': document.getElementById("fullname").value,
                       'phoneno': document.getElementById("phoneno").value,
                       'emailList': document.getElementById("email").value,
                       'stage':'@signingStage',
          

Open in new window

0
The c#/code below: how to find x,y position of 'text' for example 'signature'. and after it is found, I hope to drop the png image there.
I just need help how to find the x, y position and I already created the code dropping the png image.

Thanks

  public static string AddSignature(string originalPdf, string outputPdf, string signature, int pdfPositionX, int pdfPositionY)
        {
            string path = @"C:\Users\Documents\Workspaces\";
            string pathSignature = @"C:\Users\Documents\signature\";
            using (Stream inputPdfStream = new FileStream(path + originalPdf, FileMode.Open, FileAccess.Read, FileShare.Read))
            using (Stream inputImageStream = new FileStream(pathSignature + signature, FileMode.Open, FileAccess.Read, FileShare.Read))
            using (Stream outputPdfStream = new FileStream(path + outputPdf, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                var reader = new PdfReader(inputPdfStream);
                var stamper = new PdfStamper(reader, outputPdfStream);
                var pdfContentByte = stamper.GetOverContent(1);
                iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);

                //begin: need logics to find keyword
                PdfReader pdfReader = new PdfReader(path + outputPdf);
                for (int page = 1; page <= pdfReader.NumberOfPages; page++)
                {
                    ITextExtractionStrategy strategy 

Open in new window

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
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
I have a database called cars and had fields make and model

And I also have a pdf with two fields make and model

And I want to use itextsharp to map the fields and fields value in a loop meaning that while reading table i just want to loop all of fields. Because the table has over 200 fields when we expand. I don’t want to code the field name one by one.

And the field name on database and pdf are the same

I use mvc c#
0
I use google map and marker to display many locations on the map. However, many location like apartments 1,2,3 to 20 has the same locations and it is very hard on UI experience. Do u know anyway to resolve this map?

On each marker, I also have small detail box to show details info.

I use mvc 4 with razor engine

Thanks
0

.NET MVC

402

Solutions

299

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
>