.NET MVC

417

Solutions

301

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

Hi,

I'm trying to export my data to an excel document.

this is my first time doing it in MVC C# so I need your help please.

Do I need to create a view document for "ExportToExcel " ?

I'm doing the example that is in this URL:
https://www.yogihosting.com/export-excel-asp-net-mvc/


Thank you for your help ;-)

Filtering the data in my model

    public List<RuleDetail> RuleDetailList(CABRSearchRules model)
        {
            List<RuleDetail> modelList = new List<RuleDetail>();

            IEnumerable<CABR_RuleDetail> list = new List<CABR_RuleDetail>();
            IEnumerable<CABR_HistoryRuleDetail> Historylist = new List<CABR_HistoryRuleDetail>();

            if (model.SelectedCurrentOrHistoryID == 1) //Current
            {
                list = _unitOfWorkCABusinessRules.RuleDetailRepo.GetAll().ToList();

                //Filter Status
                if (model.SelectedStatus != null)
                    list = list.Where(x => x.isActive == model.SelectedStatus);

                //Filter Environment
                if (model.SelectedEnvironment != "All")
                    list = list.Where(x => x.Environment == model.SelectedEnvironment);

                //Filter Version
                if (model.SelectedVersion != null)
                    list = list.Where(x => model.SelectedVersion.Any(m => Equals(x.Version, m)));

                //Filter CQ Ticket
                if (model.SelectedCQticket != null)
                    list = 

Open in new window

0
Hi,

My between date is not working

I'm only getting one record instead of three

I don't know what I'm doing wrong.

I tried without parsing it and that didn't work.

        public DateTime FromCreatedDate { get; set; }
        public DateTime ToCreatedDate { get; set; }

list = list.Where(x => x.CreatedDate >= DateTime.Parse(model.FromCreatedDate.ToString()) && x.CreatedDate <= DateTime.Parse(model.ToCreatedDate.ToString()));

Open in new window

0
Hi,

I'm working with linq and need your help please.

I have a string[] SelectedVersion that I pass from my view to the controller.

I want the linq to return query that contain the string SelectedVersion[]

list = _unitOfWorkCABusinessRules.RuleDetailRepo.GetAll().ToList();

list = list.Where(x => x.Version.Contains(model.SelectedVersion));

model.SelectedVersion is a string array 
x.Version is a string 

Open in new window



the error says: " I cannot convert string [] to string "

how can I solve this syntax?
0
Hi,

How can I show all selected items after the submit?

Can someone help me and tell me what I'm doing wrong please?

Model :


        public IEnumerable<SelectListItem> VersionList { get; set; }

        public List<string> SelectedVersion { get; set; }


      public IEnumerable<SelectListItem> GetVersion()
        {
            var GetVersion = _unitOfWorkCABusinessRules.RuleDetailRepo.GetAll().GroupBy(x => x.Version).Select(y => y.First()).Distinct();

            return GetVersion
                 .Select(x => new SelectListItem
                 {
                     Text = x.Version,
                     Value = x.Version.ToString(),
                 })
                .Distinct()
                .OrderBy(x => x.Text);
        }

Open in new window




controller: 


 [HttpPost]
  public ActionResult SearchRules(CABRSearchRules model, string[] SelectedVersion)
        {

              model.VersionList = _careAdvanceBusinessRulessService.GetVersion();
            model.SelectedVersion = SelectedVersion.ToList();

      return View(model);
        }

Open in new window




        $('#SelectedVersion').multiselect({
            onInitialized: function (option, checked) {
                var values = [];
                var dropdown = $('#SelectedVersion').siblings('.multiselect-container');
                $('#SelectedVersion option').each(function () {
                    values.push($(this).text());
                });
            },
            enableFiltering: true,
            buttonWidth: '350px',
            maxHeight: 200,
            enableCaseInsensitiveFiltering: true,
        }); 



 @Html.DropDownListFor(m => m.SelectedVersion, new SelectList(Model.VersionList, "Value", "Text"), new { @multiple = "multiple" } )

Open in new window

0
Hi,

I'm creating a search page

1. on the page there is a multiselect dropdown list
2. I select some options from the list
3. I click on the submit button
4. after submitting the page my selection will get cleared out

How can I get my selection back once I click on the submit button?


 $('#SelectedVersion').multiselect({
            onInitialized: function (option, checked) {
                var dropdown = $('#SelectedVersion').siblings('.multiselect-container');
  
               //Here I want to reselect the options that I have already selected after submitting my form
               onInitialized: function (option, checked) {
                var values = [];
                var $SelectedOptions = $(this).find('option:selected');
                $SelectedOptions.each(function () {
                    values.push($(this).text());
                });
            },

            enableFiltering: true,
            buttonWidth: '350px',
            maxHeight: 200,
            enableCaseInsensitiveFiltering: true,
        }); 

Open in new window




<td>
                       @Html.DropDownListFor(m => m.SelectedVersion, new SelectList(Model.VersionList, "Value", "Text"), new { @multiple = "multiple" } )
                    </td>

Open in new window

0
Hi,

I am working on C# MVC application.

I have payment integrated in my website. For payments, we call payment url which is loaded in iFrame.
We have no control on the form which opens in iFrame, as it captures credit card details.

Now, once user does the payment by clicking submit button in payment form, which (submit form) is in iFrame.

After successful/unsuccessful transaction we are receiving response in handler page.

After getting response in handler page we are losing session of our web application.

It works well in chrome but does not work in IE, Firefox.

What we should do so that we should not loose our session once the redirect happen.

Also, we see Chrome has same id before and after confirmation done.

But other browser gives us different session id's when returns from payment page.

Please advise the solution.

I have below configuration in my web.config already.
<httpCookies httpOnlyCookies="true" requireSSL="false" />
0
I am trying to increase the width of an Html.TextBoxFor control in an ASP.NET MVC 5 View page using razor syntax. I am using Visual Studio 2017. I created a css style (textboxfor) to increase the control's width as shown below but it is not working.

Below is the MVC View:


@using rgmsite.Models
@model LoginTestViewModel
@{
    ViewBag.Title = "Log in";
}

<style type="text/css">
    .textboxfor-width {
        width: 700px;
    }
</style>

<h2>SimpleTest</h2>
        <section id="loginForm">
            @using (Html.BeginForm("Login", "Account",
              new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post,
              new { @class = "form-horizontal", role = "form" }))
            {
                @Html.AntiForgeryToken()
                <div class="form-group">
                    @Html.TextBoxFor(m => m.Email,
                   new {  @class = "form-control textboxfor-width",
                       placeholder = "Enter email address to be used as your user name"
                   })
                </div>
            }
        </section>

Below is the View Model being used:


  public class LoginTestViewModel
  {
    public string Name { get; set; }
    public string Email { get; set; }
  }

Using a smaller width value such as 40px in the css .textboxforworks.  But there seems to be some limit imposed on the control preventing it from being wider (such as 400px) than the default. What needs to be done to make the …
0
I have the following codes in layout page in MVC project.
And I want to use mvc cache. e.g. within 8 hours using the cache. Is it possible?


<li>
                                            <span><a href="#"><i class="icon-bus"></i> Class A</a></span>
                                            <ul>
                                                @foreach (Domain.Fleet fHostAdmin in rv.FleetActiveList(locationName))
                                                {
                                                    if (fHostAdmin.FleetClassType.Substring(0, 1) == classAString)
                                                    {
                                                        <li><a href="@DomainHelper.Generic.GethttpType(Request.ServerVariables["HTTPS"], HttpContext.Current.Request.Url.Authority)/Home/Detail/@fHostAdmin.QuickFindKeyWord?fleetID=@fHostAdmin.Oid"><i class="icon-check"></i> <b>@fHostAdmin.FleetClassType</b>: @fHostAdmin.FleetName <label style="color:red;">(@fHostAdmin.FleetBaseRatePricingLabel)</label> </a></li>
                                                    }
                                                }
                                            </ul>

                                        </li>

Open in new window

0
Hi,
I start by saying this is the first project I have ever published and apologize in advance if I give you too much or too little information.
So, I published this MVC project to a business server.  It works but the data in the datatable is not showing. Although, when I just debug in Visual Studio there is data.
This project has 2 tabs:  
The first tab is to show the datatable in question which uses Entity Framework;  
The second tab also has a datatable(a yadcf) which shows data that is accessed via Ado.Net.
Data in the first tab does not show, while it does in the second tab.  


The datatable on the first tab references to this link:
 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>

While for the second tab I imported the yadcf datatable. Below is how I reference to it:
<script src="~/Yadcf/jquery.dataTables.yadcf.js"></script>  


Also, when I do F12 under the "Elements" I can see the references to the datatables(see attached photo).  Plus it looks like the datatable and its functionalities(search box, paging, column names) show up but without any data in it.


IN CASE YOU WANT TO SEE IT, THIS IS THE CODE OF THE INDEX PAGE WHICH INCLUDES THE DATATABLE:
`
@{
    ViewBag.Title = "Index";
}

<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#firstTab">View All</a></li>
    <li><a data-toggle="tab" href="#secondTab">Add New</a></li>
  

Open in new window

0
Hi,
I published a MVC project to a business server.  It works but the data in the datatable is not showing.
Although, when I just debug in Visual Studio there is data.
This project has 2 tabs:  
The first tab is to show the datatable in question which uses Entity Framework;  
The second tab also has a datatable which shows data that is accessed via Ado.Net.
Data in the first tab does not show, while it does in the second tab.  


Could the problem be that while the datatable on the first tab references to this link
 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>

while for the second tab I imported the yadcf datatable
<script src="~/Yadcf/jquery.dataTables.yadcf.js"></script>   ?



FYI, when I published I used the below:

UNDER CONNECTION:
Publish method: Web Deploy
Server:  (Business Server Name)
Site name:  HelpDeskSupport
Username:  myUsername
Password:  myPassoword

UNDER SETTINGS:
Under "DBModel" as the datasource I added the SQL Server name with its username and password.
I checked the "Use this connection string at runtime..."



Could you please help me figure out what I have done wrong? Thank you.
0
I am new in Web API, and I want to have a step by step guide using VS 2010 and VB.NET. An Important concept is how to secure the API... If what I need is achievable... can any of you recommend a book for that. I appreciate your help
0
Hi,

I need your help!

I can upload any file type to a folder and save the name and path to the database.
I'm also able to list all the attached files based on the selected record.

My next step is to let the user view what they have uploaded to the server folder.

I'm not sure how to do this step

do you have any example that might help me?

//when the user click on the button ViewFileBtn
I need to be able to upload the file and give them the option to save or view the file. 


Do I have to create a popup window to uploaded the downloaded file?



@foreach (var FileUploadedList in Model.UploadedFilesList)
                {
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            @FileUploadedList.FileID <span>| </span>@FileUploadedList.Name <span> | </span> @FileUploadedList.Path
                            <button id="ViewFileBtn" name="ViewFileBtn" class="btn btn-default" type="button" style="margin-top:10px;margin-bottom:10px;" value="@FileUploadedList.FileID">
                                View File
                            </button>
                           

                        </h3>
                    </div>
                }

Open in new window

0
Hi,

This is my first linq and I'm not sure what I'm doing.

I need your help please.

I have to tables:

Table:
CABR_RuleIdentifier
RuleIdentifierId
RuleSetId
RuleIdentifier
IsActive


Table:
CABR_RuleDetail
RuleDetailId
isActive
RuleSetId
RuleIdentifierId
Version
Environment


I need to do this in linq:

SELECT RuleDetailId, isActive, RuleSetId, RuleIdentifierId, Version, Environment
FROM CABR_RuleDetail
LEFT JOIN CABR_RuleIdentifier
ON CABR_RuleDetail.RuleSetId = CABR_RuleIdentifier.RuleSetId; 


           CABR_RuleDetail RuleDetailResult = new CABR_RuleDetail();
            var result = from CABR_RuleDetail in RD
                         join CABR_RuleIdentifier in RI
                         on RD.RuleSetId equals RI.RuleSetId into ResultData
                         from RuleDetailResult in ResultData.DefaultIfEmpty()
                         select new
                         {
                             CABR_RuleDetail.RuleDescription,
                             CABR_RuleDetail.RuleDetailId,
                             CABR_RuleDetail.isActive,
                             CABR_RuleDetail.RuleSetId,
                             CABR_RuleDetail.RuleIdentifierId,
                             CABR_RuleDetail.Version,
                             CABR_RuleDetail.Environment,
                             CABR_RuleIdentifier.RuleIdentifier
                         };

Open in new window

0
Hello Experts,

I have MVC 5 asp.net application(using jquery), On a page if I click Add where it shows modal popup with two fields Name and Age  and it has Required field validators. It shows when try to save without entering both the fields and on cancel button the modal popup close and it goes back to page(which has grid). When I click row Edit on grid, the popup shows the Validation messages under the textbox.

<div class="col-md-3 col-lg-3 col-3">
                            <div class="form-group m-b-40">
                                <input type="text" id="Name" name="Name" value="" class="form-control" required="required" autofocus="autofocus">
                                <span class="bar"></span>
                                <label for="Name">Name*</label>
                            </div>
                               <div class="form-group m-b-40">
                                <input type="text" id="Age" name="Name" value="" class="form-control" required="required" autofocus="autofocus">
                                <span class="bar"></span>
                                <label for="Age">Age*</label>
                            </div>
                        </div>

Open in new window


I tried below suggestions this(on cancel button) and still same issue
https://stackoverflow.com/questions/2798427/how-do-i-clear-mvc-client-side-validation-errors-when-a-cancel-button-is-clicked

Thanks,
ASPDEV
0
Hi,
I am displaying data on the ViewAllTasks page which has a delete, an edit and an add.  They all work except for the update one.  I do not get any errors and the program seems to run fine but the database is not updated and the view is not updated as well.
The add does something similar and it works:  it inserts a record in the database and the view is updated via the loadData() javascript.  What is it that I am doing wrong?  Please help.  Thank you

JAVASCRIPT:
//Load Data in Table when documents is ready
$(document).ready(function () {
    loadData();
});

//Load Data function
function loadData() {
    $.ajax({
        url: "/Tickets/ListITTasks",
        type: "GET",
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (result) {
            var html = '';
            $.each(result, function (key, item) {
                html += '<tr>';
                html += '<td>' + item.ITNumber + '</td>';
                html += '<td>' + item.ITDescription + '</td>';
                html += '<td>' + item.ITEnterDate + '</td>';
                html += '<td>' + item.ITAssignedTo + '</td>';
                html += '<td>' + item.ITEstimatedCompletion + '</td>';
                html += '<td>' + item.ITPriority + '</td>';
                html += '<td>' + item.ITFrom + '</td>';
                html += '<td>' + item.ITStatus + '</td>';
                html += '<td><a href="#" onclick="return getbyTicketNumber(' 

Open in new window

0
Hi,
I have a main view which has a "Comments" link on each row that when clicked it opens up a partial view. The partial view displays a table and textboxes, and an "Add" button that when clicked it adds the data entered in the textboxes to the table.

The first time I click on comments, I add data to the textboxes and hit the Add button and everything works.

The problem is:  when I open the partial view from another record(by clicking on Comments) and add data to the textboxes, after I click on add it adds an extra blank row.  It is as if the add button is clicked twice.  Could you please help me solve this issue?  The code I am using is below.
Thank you very much.

**PARTIAL VIEW:**
        @model IEnumerable<HelpDeskSupport.Models.Comment>

        <html>
        <body>
    <table class="table table-striped table-bordered" cellpadding="0" cellspacing="0" border="0" width="1500" id="tblComments">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.TicketNumber)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Comment1)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.AssignedTo)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.CreatedBy)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Date)

Open in new window

0
Hi,
I have a main form displaying data.  Then I have a "Comments" link on each row and on the click of it a partial view with a table opens up.  The partial view is to view/add comments and other data.  In this partial view, after the table, there are textboxes I can fill with data.  After adding data I click on "Add" and when I am done I would click on "Save" and whatever I typed in the textboxes is entered in the database.  This all works and gives you an idea of what I am working with(see attached pics as well).  

What I am looking for now is a way to fill the Ticket Number textbox(on the partial view) with the number from the Number field(on main form).  Also, this number should not be edited on the partial.  How can I achieve that?

I have been unable to find a solution.  Please help.  Thank you.

THIS IS THE CODE IN THE CONTROLLER:
//VIEW ALL COMMENTS AND DISPLAY IN PARTIAL
        [HttpPost]
        public ActionResult ViewComments(int ticketNum)
        {
            List<Comment> AllComments = new List<Comment>();
            using (DBModel db = new DBModel())
                AllComments = db.Comments.Where(x => x.TicketNumber == ticketNum).ToList();

            return PartialView("ViewComments", AllComments);
        }


//INSERT COMMENT
        public JsonResult InsertComments(List<Comment> commentsArray)
        {
            using (DBModel db = new DBModel())
            {
                //Truncate Table to delete all comments. 

Open in new window

0
The following codes came from mvc action result.
Assume the message return string called "file 1"
Using javascript, how to get value (which is file 1).

Thanks

 if (isSavedSuccessfully)
            {
                return Json(new { Message = fName });
            }

Open in new window

0
Hi,

my Group select is not triggering my on change event.

1. I have a select dropdown list that select px or dx .....
2. Upon selecting from the first dropdown list the Group select will get populated with a list of dx or px.....
3. ounce the user select from the list of dx or px I need to populate the textarea with the list Item.
but for some reason my Group Select is not triggering my on change event to send the data to the textarea called ItemsTextArea

<script>
    $(document).ready(function () {

       // debugger;

        $('#OperatorSelect').multiselect(getOperatorOptions(true));
        $('#ConditionSelect').multiselect(getOperatorOptions(true));
        $('#ValueSelect').multiselect(getOperatorOptions(true));
        $('#GroupSelect').multiselect(getGroupOptions(true));


        $("#ConditionSelect").change(function (event) {
            var GetValue = $(this).val();
            $('#HiddenFieldForSelectedCondition').val(GetValue);
            var method = $('#RulePartialViewForm').attr("method").toLowerCase();
            var action = $('#RulePartialViewForm').attr("action");
            var data = $('#RulePartialViewForm').serialize();
            $.ajax({ method: method, url: action, data: data }).done(
                function (json) {
                    var arr = [ '<option>Select</option>' ];
                    $.each(json, function (i, obj) {
                        arr.push('<option value="' + json[i].Value + '">' + json[i].Text

Open in new window

0
Hi Experts,
I want to convert this simple query to a LINQ query in C#.
select distinct c.MemberID,max(c.approved)  from Claims c
join member m on c.MemberID = m.MemberId
where m.Id = 910318 and  c.PointsEarned > 0 group by c.MemberID

Open in new window

Any help is appriciated!
Thanks in advance.
0
Hi,

How can I send back my model info to the dialog box ounce I submitted its form.
right now it's asking me to save json file after my submission

         [HttpPost]
        public JsonResult RulePartialView(CABRRulePartialViewModel model)
        {
            model.SelectGroupDataListSource = _careAdvanceBusinessRulessService.GetGroupse();
            model.SelectGroupDataSource = _careAdvanceBusinessRulessService.SelectedDataFromGroup(model.HiddenFieldForSelectedCondition);

            Thread.Sleep(1000);
            return Json(model, JsonRequestBehavior.AllowGet);
}

Open in new window



my dialog box partial view


@model BCUW.Model.CABusinessRules.CABRRulePartialViewModel




<script >
    $(document).ready(function () {

        debugger;

        $('#OperatorSelect').multiselect(getOperatorOptions(true));
        $('#ConditionSelect').multiselect(getOperatorOptions(true));
        $('#ValueSelect').multiselect(getOperatorOptions(true));
        $('#GroupSelect').multiselect(getGroupOptions(true));

        
        $("#ConditionSelect").change(function () {
            var GetValue = $(this).val();
            $('#HiddenFieldForSelectedCondition').val(GetValue);
            
            $('#RulePartialViewForm').submit();
        });


        function getOperatorOptions(isFilter) {
            return {
                buttonWidth: '170px'
            }
        }


        function getGroupOptions(isFilter) {
            return {
                

Open in new window

0
Hi,

my dialog box has the word "close" on top right
 
how can I remove it?

Thanks,


  $(function () {
            $('#dialog').dialog({
                autoOpen: false,
                width: 800,
                height:600,
                resizable: true,
                title: 'Product',
                modal: true,
                open: function(event, ui) {
                    $(this).load("@Url.Action("RulePartialView", "CareAdvanceBusinessRules")");
                },
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");
                    }
                }

            });
            $("#opener").click(function (event) {
                event.preventDefault(); 
                $("#dialog").dialog("open");
            });
        });

  <div id="dialog" title="Basic dialog"> </div>

    <a id="opener" href="@Url.Action("RulePartialView", "CareAdvanceBusinessRules")">Click to open popup window </a>

Open in new window

0
Hi,
When I click on my link, it takes me to a whole new page instead of opening my partial view page in a popup window.
I’m not sure what I’m doing wrong can you please take a look and let me know
Thanks,


Controller: 
      public ActionResult RulePartialView()
        {
            CABRRulePartialViewModel model = new CABRRulePartialViewModel();

            return PartialView(model);
        }

Open in new window


Index page: 

    $(document).ready(function () {
$(function () {
            $('#dialog').dialog({
                autoOpen: false,
                width: 400,
                height:500,
                resizable: false,
                title: 'Product',
                modal: true,
                open: function(event, ui) {
                    $(this).load("@Url.Action("RulePartialView", "CareAdvanceBusinessRules")");
                },
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");
                    }
                }
            });
            $("#opener").click(function () {
                $("#dialog").dialog("open");
            });
        });

  });


    <div id="dialog" title="Basic dialog"> </div>

    <a id="opener" href="@Url.Action("RulePartialView", "CareAdvanceBusinessRules")">Click to open popup window </a>

Open in new window


Partial view page 

@model BCUW.Model.CABusinessRules.CABRRulePartialViewModel

<p>hello this is the partial view page</p>

Open in new window

0
In my MVC project I created a tab called "Knowledge". I was finally able to make some things work. I implemented a YADCF datatable on it but it is not working. The datatable features appear to be there but not the yadcf. I included the code below and the images of the three errors I get in the console. Please help, thank you!

Here is my code:

       
@model IEnumerable<HelpDeskSupport.Models.KnowledgeBaseModel>

    @{
    Layout = null;
    }

<!DOCTYPE html>

<head>
    
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/yadcf-master/jquery.dataTables.yadcf.css"></script>
    <script src="~/yadcf-master/jquery.dataTables.yadcf.js"></script>
    <script src="~/DataTables/datatables.css"></script>
    <script src="~/DataTables/datatables.js"></script>

    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

    </head>
    <table class="display table table-striped table-bordered" id="knowledgeTable">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.KBSubject)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.KBFrom)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.KBAssignedTo)
            </th>
            <th>
                

Open in new window

0
Hello!!!

I have an input form and on that form the user should be able to upload multiple files.  

I have the UI / Jquery uploading multiple files and deleting multiple files working great.

the problem that I have is in my controller, I don't know how to get the files into my model with multiple unlimited files.

Let me show you what I have

//With this code user can upload and remove multiple files: 

    $(document).ready(function () {

        $("#FileCount").val("");

    });




//Begin multiple file upload
    var counter = 0;
    function AddFileUpload()
    {
        var div = document.createElement('DIV');

        div.innerHTML = '<button class="btn btn-default glyphicon glyphicon-remove" style="height:41px; padding: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; width:80px;border: 1px solid #BBB;cursor:pointer;" id="Button' + counter + '" type="button" ' +
          'value="Remove" onclick = "RemoveFileUpload(this)" >' +
          '</button>'  +

        '<input id="file' + counter + '" name = "file' + counter +
        '" type="file" class="fileStyle" />';

        document.getElementById("FileUploadContainer").appendChild(div);

        counter++;

        $('#FileCount').val(counter);

    }


    function RemoveFileUpload(div)
    {
        var el = document.getElementById("FileUploadContainer");
        el.removeChild(div.parentNode);
        var children = el.getElementsByTagName('input');
        counter = 0;
        for 

Open in new window

0

.NET MVC

417

Solutions

301

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.