.NET MVC

371

Solutions

282

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

I have mvc razor form and look for a esign pad so the user can sign. also need api to get the signature
0
Should you be charging more for IT Services?
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

I have the following json string. how  to read it in c# FOR  LOOP?

{Employee:[{"principalfirstname":"xxx","principallastname":"xxx","principalmiddlename":"xxx","principalnameonbond":"xxx","principaldba":"xxx","principalentity":"USA","principalyearinbusiness":"xxx","principaltaxid":"","principaladdress":"xx","principalcity":"xxx","principalstate":"TN","principalzip":"111","principalcounty":"","principalphoneno":"xxx","principalemail":"","principalfaxno":"","vin":"","licenseplatenumber":"","driverlicensenumber":"","door":"","bondstate":"","bondamount":"","premium":"","bondterm":"","creditcardfullname":"","creditcardnumber":"55555555533331111","creditcardchargeamount":"","creditcardexpdatemm":"","creditcardexpdateyyyy":"","creditcardcvc":"","creditcardaddress":"","creditcardcity":"","creditcardstate":"","creditcardzip":""}]}

Open in new window

0
I have this string in json {"columnC":"1","columnA":"2","columnB":"2"}
How can I use for loop to generate  like

ColumnC: 1
ColumnA: 2
ColumnB: 2

Thanks
0
I have Json & MVC / c# question below:

the var json = JSON.stringify(data); return json format
like {"column":"1","columnA":"2"}

My question is inside of the C# mvc ReceiveJson: How to extract the value like

column = 1
columnA = 2

and i want to be like insert table column, columnA values (1,2)

And {"column":"1","columnA":"2"} is it a json format?

*** formdiv *** inside of it, it just a combination of some <input id='column'> or <select id='columnA'>
function Submit(domain) {
    var x = $('#formdiv *').serializeArray();
    var data = {};
    $.each(x, function (i, field) {
        data[field.name] = field.value;
    });
    var json = JSON.stringify(data);
    alert(json);
    $.ajax({
        url: domain + "/Api/ReceiveJson",
        type: "POST",
        data: {
            'message': json
        },
        dataType: 'json',
        success: function (data) {
            alert(data.BondCode);
        },
        error: function (msg) { alert(msg); }
    });
    return false;
}

[HttpPost]
        public JsonResult ReceiveJson(List<string> message)
        {             
            var jsonResult = Json(message);
            domainCompanyBondType.BondCode = "1";
            return Json(domainCompanyBondType, JsonRequestBehavior.AllowGet);
        }

Open in new window

0
I use vector map. and I hope to capture the selected US state (california) on click when California area is clicked, and then pop up a modal. so I can take the selected state (California) and develop some api call.

Do you know how to do that? Just capture the state and get modal up.



http://jvectormap.com/maps/countries/usa/
0
I have the following ajax codes, and want to send Json data to MVC Controller.
Can you show me how to do that  on MVC Controller?
Thanks

function Submit(domain) {
    //alert("Thank You");
    var x = $('#formdiv *').serializeArray();      
    var data = {};
   $.each(x, function (i, field) {
        data[field.name] = field.value;
   });
    var json = JSON.stringify(data);   
    alert(json);
    $(document).ready(function () {
        $.ajax({
            url: domain + "/Api/ReceiveJson",
            type: "POST",
            data: {json},
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            success: function (data) {alert('Success');},
            error: function (msg) { alert(msg); }
        });
    });
    return false;
}

Open in new window

0
I'm new to MVC and have inherited an MVC code-base.

I simply want the user to have to check a box to agree with terms and conditions. The code below let's the user proceed whether they have check the CheckBoxFor.AuthorizeAchTransaction  or not.

VIEWMODEL
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyProject.ViewModels
{
    public class ACHViewModel
    {
        [Display(Name = "Routing Number")]
        [Required]
        [RegularExpression("^((0[0-9])|(1[0-2])|(2[1-9])|(3[0-2])|(6[1-9])|(7[0-2])|80)([0-9]{7})$", ErrorMessage = "Invalid Routing Number")]
        public string ACHRoutingNumber { get; set; }

        [NotMapped] // Does not effect with your database
        [Display(Name = "Routing Number (Confirm)")]
        [System.ComponentModel.DataAnnotations.CompareAttribute("ACHRoutingNumber", ErrorMessage = "Routing number doesn't match.")]
        [Required]
        public string ConfirmACHRoutingNumber { get; set; }

        [Display(Name = "Account Number")]
        [Required]
        public string ACHAccountNumber { get; set; }

        [NotMapped] // Does not effect with your database
        [Display(Name = "Account Number (Confirm)")]
        [System.ComponentModel.DataAnnotations.CompareAttribute("ACHAccountNumber", ErrorMessage = "Account number doesn't match.")]
        

Open in new window

0
I use mvc host to write some mvc razor webpage on dnn 9. and I also my own dll library that I want to import and use it as reference on razor webpage.  is it possible?

I also want to see if I can use dapper with mvc razor.

thanks
0
I have been tasked to create a Spotlight type of report.  I am thinking the best way to get all the data I need for each "cell" of the report would be to create a Stored Procedure the contains multiple output parameters with the result of each cell rather than creating multiple methods in a partial model or something like that.  

I need some advice, tips or any help on how to add a Stored Procedure with out put parameters to my EDMX and then use that data in a View.
0
Do you know where I can download MVC AdminLTE combination with MS SQL Server to manage the users/roles and etc?
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

I tried to get mvc class inside of javascript like below. but it alerts that fixed up with javascript codes. Is it a way to use mvc inside of javascript?

@MasterHelper.Generic.DecryptPassword(data[index].passcode);


 function UserInfo()
    {
        var userid = localStorage.getItem("userid");
        $(document).ready(function () {
            $.ajax({
                url: "/Api/UserInfo",
                datatype: "text",
                type: "POST",
                data: { 'userid': userid},
                dataType: 'json',
                success: function (data) {
                    $.each(data, function (index) {
                        var test = data[index].passcode; 
                        document.getElementById("firstname").value = data[index].firstname; 
                        document.getElementById("lastname").value = data[index].lastname; 
                        document.getElementById("passcode").value = @MasterHelper.Generic.DecryptPassword(data[index].passcode); 
                        document.getElementById("emailadr").value=data[index].email;                            
                    });
                },
                error: function (msg) { alert(msg); }
            });
        }); 
    }

Open in new window

0
I have multiple modals one page.  There are opened from a partial view. When I open a modal the first time all functionality is working as expected.  However when a second modal is loaded certain functionality is broken like auto-focus and jQuery accordion are no longer working.  I believe it's because the modal is not being properly destroyed and or removed from the DOM.  However I'm unsure on how to destroy the modal properly.

Button to open modal
<a class="fa fa-info btn btn-link" href="#" onclick="ShowExamDetails(@item.user_exam_id)"> Details</a>

Open in new window



Modal
     <div class="modal" id="myModalDetails" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h5 class="modal-title" id="exampleModalLabel"><strong style="color:#285e8e"> Details of</strong> User Exam</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body" id="myModalBodyDiv">
                                @*Partial View Renders Here*@
                            </div>
                            <div 

Open in new window

1
Hi Experts,
How can i show a simple modal pop up in MVC? I have a log in page. When it is a valid login, it takes me to the main page. On the top of main page I need modal pop up with a messge "Welcome X" and some other static contents.

Please help.
Thanks in advance!
0
I am creating the WebGrid on the code behind, and am trying to get the cell value so I can format depending on the value.

This is the code I am currently using to populate the WebGrid which works well.  I would like to loop through the rows get a certain cell value and then change the font color how can I do that?

            IGrid<LastActivity> grid = new Grid<LastActivity>(rptRepository.GetLastActivity());
            grid.ViewContext = new ViewContext { HttpContext = HttpContext };
            grid.Query = Request.Query;

            grid.Columns.Add(model => model.OppOwner).Titled("Owner");
            grid.Columns.Add(model => model.OppCount).Titled("Count");


            grid.Id = "grdLastActivity";

            grid.Pager = new GridPager<LastActivity>(grid);
            grid.Processors.Add(grid.Pager);
            grid.Pager.RowsPerPage = 10;

            var oppcount = grid;

            foreach (IGridColumn column in grid.Columns)
            {
               
                column.Filter.IsEnabled = false;
                column.Sort.IsEnabled = true;
 
            }

            return grid;

Open in new window

0
I am receiving the following error always when this method is executed through Window Service whether when the same code is executed through Web Portal it is working Fine.

Could not create ssl/tls secure channel. c#


using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using System.Net;
using Newtonsoft.Json.Linq;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;


 void wc1TwoSample2()
        {
            try
            {
                ServicePointManager.ServerCertificateValidationCallback +=
                delegate(Object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                {
                    return true;
                };
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.DefaultConnectionLimit = 9999;
                //ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
                System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
                ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(delegate { return true; });
                string URL = "https:URL";
                string param = "/api/v1/accounts";
                string resp = URL + param;
                var http = 

Open in new window

0
I am using Entity Framework 6 in an MVC 5 project with a SQL database. One of the tables in the database uses integer values for the status_id. I want to assign those values a name in the view rather than presenting the integers. I am having difficulty determining the best way to handle this. My first thought was using a foreach loop but I am having difficulty with the syntax and that may not be the best route.

Relevant part of the View to this question (code remove for brevity)

@model Models.Meeting

@{

    ViewBag.Title = Model.Customer1.Name;
}

<body>
    <div id = "MeetingDetails" class="EmailDetails">
        <h2>Meeting Details</h2>
        <hr />
        <dl class="dl-horizontal">
            <dt>
                @Html.DisplayNameFor(model => model.Customer1.Name)
            </dt>
            <dd>
                @Html.DisplayFor(model => model.Customer1.Name)
            </dd>
            <dt>
                @Html.DisplayNameFor(model => model.Customer1.status_id)
            </dt>
            <dd>
                @Html.DisplayFor(model => model.Customer1.status_id)
            </dd>
            <br />
        </dl>
    </div>
</body>

Open in new window


Relevant portion of Controller (code removed for brevity)
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Meeting meeting = db.Meetings.Find(id);
            if (meeting == null)
            {
                return HttpNotFound();
            }
            foreach (string download in Request.Files)
            {
                if (Request.Files[download].FileName != "")
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + "/uploads/";
                    string filename = Path.GetFileName(Request.Files[download].FileName);
                    Request.Files[download].SaveAs(Path.Combine(path, filename));
                }
            }
            return View(meeting);
        }

Open in new window


Model Diagram
Model Diagram for Two Tables
Partial screenshot of Details View. The value in the Prospect Status row is the integer value in the status_id in the Customer table.

TestMeetingDetailsScreenshot.JPG
0
I have the following api to call MVC.net controller, and it works just fine.
Now, I have some service called https://api.xxx.com/Accounting/Test and I replace it but it is not working.
The  c# parameters and method is  the same. so do you have any ideas what is going on?

 $.ajax({
            url: "/Accounting/Test",
            dataType: 'json',
            data:
            {
                'asso': assoValue
            },

Open in new window

0
on my mvc, I want to the its identity and role based option. I understood there is google, facebook, and etc.
and I own have a custom Single Sign on for one of the providers for our own business. Let us call it FirstSSO
and I want FirstSSO to be used by default. Just assume that someone put login/password in  the form, and it  will take FirstSSO first instead of the using local MS SQL for auth.

Thanks,
0
I have 1000  emails that I want send by sendgrid using mvc/c#
Do you know there is better way  to implement it?
0
I need to take a view in MVC 5 and open it in Outlook. I have the printing functionality working, but the end users want the capability to click a button to open their Outlook with the contents of the view. I do not want to send the view programmatically on the server side as the end users want to be able to view it as an email on their workstations and add comments before sending to email addresses. Is this possible? I have done lots of searching online and found ways to send emails through MVC on the server side, but I have not found anything that takes a view and pastes it into an Outlook window. I do not want to use any 3rd party plugins except those which are widely used standard plugins (jquery, javascript, ajax, etc.)

Current system:
ASP.NET MVC 5
Entity Framework 6
C# with razor views
Microsoft SQL 2014
Microsoft Exchange (not hosted online)
Various versions of Microsoft Outlook

I can provide code samples for the controller and views if needed.
0
Hello;
Can I open a page in an Internet Explorer through a page in a Chrome browser?
In other word, regardless of the browser type that I'm residing in, I need when click on HTML link to open it in IE only, for that particular link only.
C#, MVC, javaScript
please help.
0
i have the following in the cshtml file

  @Html.Action("LoadImage")

Open in new window


This works fine
Now I need to pass in an ID to the

i.e.   @Html.Action("PaintImage", $('#ddlSiteId').selectedValue)

how would i acheive this?
0
Is ASP.NET MVC 5 the title for ASP.NET Core?  The reason why I ask is because the ASP.NET MVC 5 tutorial on the Microsoft website starts you on the path of a ASP.NET Core project.  Thanks!
0
Hi

I have a site that loads different logos etc depending on the URL you enter on


I have the following areas in a _Layout.cshtml file

<title>@ViewBag.PageTitle </title>
   <img id="logo" src="@ViewBag.Logo" />

       <span class="txt-color-white">@ViewBag.Footer</span>

Open in new window


then in the controller I populate these
     ViewBag.Logo = site.BrandingLogo;
                ViewBag.Title = site.BrandingPageTitle;
                ViewBag.Footer = site.BrandingFooter;

Open in new window



This all works fine for these
 
public ActionResult Index()
  ..
 return View();

Open in new window



However its not working for this

public ActionResult LoadGraph(string GroupId)
..
return PartialView(model);

Open in new window


I assume because its a partial view and not a view?


Can you suggest a way to get this working with a paritial view

Or better yet do this population of the layout in one place rather than every view for different pages?
0
I have a web application that is leveraging Telerik RadGrid to display database content. Framework is MVC with C#. I am trying to display a bootstrap alert with a message "Record Successfully Added". The issue is the Bootstrap Alert is never displayed. When I move the code to a page without the RadGrid, the Alert displays perfectly...So I believe this is a timing issue. I believe the placement of the Alert could also be the issue, but I can't seem to get this to work. See chtml code below. @Html.Action("ShowAlert") is the call for the Alert which I can run in debug and see the alert populated.

@{
    ViewData["Title"] = "Meals";
    ViewData["Icon"] = "fa-utensils";
    ViewData["Subtitle"] = "Stay tuned, wonderful content will arrive here soon.";
}

<div class="br-section-wrapper">
    @Html.Action("ShowAlert")

    @(Html.Kendo().Grid<synergix365.Models.Maintenance.Master.Meals>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(p => p.Meal_ID).Title("Meal ID").Visible(false);
                    columns.Bound(p => p.Coop_ID).Title("Co-op ID").Visible(false);
                    columns.Bound(p => p.Meal_Name).Title("Meal Name");
                    columns.Bound(p => p.Meal_Type_ID).Title("Meal Type ID").Visible(false);
                    columns.Bound(p => p.Meal_Type_Name).Title("Meal Type");
                    columns.Bound(p => p.Charge).Title("Charge");
                    columns.Bound(p 

Open in new window

0

.NET MVC

371

Solutions

282

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.