FAQ Database Discussion Community


mvc 4 custom format validator does not show error and allows the form to submit

asp.net-mvc,validation,asp.net-mvc-4
I have the following validator for a MVC 4 view public class IpFormatValidator: ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { ValidationResult resp; if (value != null) { string ip ; IPAddress noUsed ; ip = value.ToString(); if(IPAddress.TryParse(ip, out noUsed)) { resp = ValidationResult.Success; } else { resp...

Rendering “~/bundles/jqueryval”

c#,asp.net-mvc,asp.net-mvc-4,razor
I need your help, I have written this code to render the "~/bundles/jqueryval" The view Code @model workflow.DataHolders.NewCompany <link href="@Url.Content("~/sharedfiles/css/forms/addnew.css")" rel="stylesheet" type="text/css" /> <div id="Add_container"> @if (!ViewData.ModelState.IsValid) { <div id="validationMessage">Please Correct The Errors Below</div> } @using (Html.BeginForm("ValidateAndSignUp", "Accounts", FormMethod.Post)) { @Html.AntiForgeryToken() @Html.ValidationMessage("CompanyName"); <span...

Protractor, login to asp,net MVC login page, wait for default page then , redirect to angular page and do tests…how?

c#,angularjs,asp.net-mvc-4,selenium,protractor
I'm trying to implement Protractor test on my MVC Project that we are slowly converting to Angular I login on a MVC login page, enter the login and password, Click login, then I need to wait for the login to go through several pages, and get to the default screen....

Pass a javascript variable as parameter to @url.Action()

javascript,asp.net-mvc-4,url.action
is it possible to pass a javascript variable as a parameter to @url.Action(), because as far as i know there may be server and client side issue, my requirement is i have to download the file according to filter, and ajax call doesnot work with downloading the file. so i...

Call back from server to client

c#,asp.net,asp.net-mvc,asp.net-mvc-4
I am using ASP.NET MVC 4 application, I need to Display messages in the Client, by sending messages from Controller to Client. My requirement is user click a button in UI and i will process the files on the server and Display message in UI on end of each foreach...

C# entity framework MVC second run error

entity-framework,asp.net-mvc-4,localdb
I am creating db and initializing data with code below, if DB doesnt exist, it creates db and populate it, when I run application second time I get error Cannot drop database "aspnet-app" because it is currently in use. Application_start, with initializations protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes);...

MVC 4 - pass parameter to controller on button click

asp.net-mvc-4
I have an MVC 4 project that has a save button that when clicked asks the user to confirm and then submits the whole form back to the controller with the model as input, not formCollection. Now I need to add another button to the form called Submit. How can...

MVC 5 OWIN login with claims and AntiforgeryToken. Do I miss a ClaimsIdentity provider?

asp.net-mvc,asp.net-mvc-4,razor,asp.net-mvc-5,claims-based-identity
I'm trying to learn Claims for MVC 5 OWIN login. I try'ed to keep it as simple as possible. I started with the MVC template and inserted my claims code (see below). I get an error when I use the @Html.AntiForgeryToken() helper in the View. Error: A claim of type...

Mvc: Getting the selected value of the dropdownlistFor box

asp.net-mvc-4
In my domain I have this service public class StudentService { private readonly IStudentRepository _studentRepository; public StudentService(IStudentRepository studentRepository) { _studentRepository = studentRepository; } public StudentDto DisplayStudentInformation() { var objStuSec = _studentRepository.DisplayStudentSection(); return objStuSec; } } Here is my studentDto public class StudentDto { public string StudentId { get; set; }...

access a page in the MVC Global.asax

c#,asp.net,asp.net-mvc,asp.net-mvc-4
I want to redirect to a page in the case that does not accomplish a condition in the global.asax in method application start... redirects to a warning page like this:... protected void Application_Start() { if (MyClass.Warnning == "2") { Response.Redirect("~/warningPage.aspx"); } } but it shows me the following error: response...

Using Bootstrap 3 DateTimePicker in ASP.NET MVC Project

jquery,asp.net-mvc,twitter-bootstrap,asp.net-mvc-4,bootstrap-datetimepicker
I want to use the Bootstrap 3 DateTimePicker. I added it to my ASP.NET project using NuGet. Here's my BundleConfig.cs: bundles.Add(new StyleBundle("~/Content/Bootstrap").Include("~/Content/bootstrap.css", "~/Content/bootstrap-theme.css", "~/Content/bootstrap-theme.min.css", "~/Content/bootstrap.min.css", "~/Content/less/_bootstrap-datetimepicker.less", "~/Content/less/bootstrap-datetimepicker-build.less")); bundles.Add(new ScriptBundle("~/Scripts/Bootstrap").Include( "~/Scripts/moment.min.js", "~/Scripts/bootstrap.js",...

File upload control in asp.net mvc

c#,asp.net,asp.net-mvc,asp.net-mvc-4
I have written a fileupload control in asp.net mvc.But as of now the logic what i am doing is, i am downloading excel file in to server locally and then processing data and pushing in to oracle database.But some servers due to permission issues , i am not able to...

A property of model becomes null while posting

asp.net-mvc-4
I'm new to MVC. Now I'm trying with a simple demo of MVC that to print Customer's information to screen and update it, send back to database. I have no idea why the Customer's ID becomes null while the others are fine. I want to display Customer's ID to the...

How to Implement Dependent Dropdownlist in MVC4 Razor and using SQL server also

sql-server,asp.net-mvc-4,razor
I've 2 Dropdownlist called States and Country. but only the States DDL(DropdownList) will be enable the country DDL will be diable. when I select a option in States which is already stored in SQL. The Country DDL Should Show the Selected state's Country automatically from DB. Please help Me..... Ex:If...

Use Bearer Token Authentication for API and OpenId authentication for MVC on the same application project

c#,asp.net-mvc-4,oauth-2.0,openid,identityserver3
I am trying to use both OpenId and Bearer token authentication on my application through Identity Server. The problem currently is that once I have authenticated the user, I still need to get a bearer token to be able to call any action methods for my Asp.Net MVC application. Here...

Setting up routing when RemoteAttribute specifies AdditionalFields

c#,asp.net,asp.net-mvc,asp.net-mvc-4
How to configure actions if I specify AdditionalFields for validation via RemoteAttribute to handle possible optional additional fields? Currently I try to have actions for possible combinations of optional fields and it does not work as show below. I have a form that is bound to a model and one...

How do you send data to controller with ajax.beginform?

ajax,asp.net-mvc-4,razor,model-view-controller,model
This is my method on controller "sale" [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(Models.account account) { Models.sale creaventa = new Models.sale(); //creaventa.account = cliente; creaventa.createdon = DateTime.Now; creaventa.idaccount = account.id; creaventa.modifiedon = DateTime.Now; creaventa.status = 0; context.sales.Add(creaventa); context.SaveChanges(); // return "venta creada"; return View(); } and this is the partial view @model...

Partial View's checkbox state not returned to controller

c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
I have a main view whose Model is of type FacilityViewModel. The main view loads a partial view that also contains a partial view. Both partial views have a model of type FiltersViewModel. The most nested partial view loops through a dictionary and creates a checkbox for each item to...

NHibernate fluent mapping to an entity property

asp.net-mvc-4,nhibernate,fluent-nhibernate,nhibernate-mapping,fluent-nhibernate-mapping
I have a table called "Customers" and in this table there are store and office address. In the code there is a Customer class with two properties that are of type Address (one for StoreAddress and OfficeAddress). public class Customer { public virtual int Id { get; set;} public virtual...

How can I bind a list model which contains a complex type in MVC4?

c#,asp.net-mvc,asp.net-mvc-4
I have a form with input elements like this: ... <input type="hidden" name="orders[0].ID" value="1"> <input type="text" name="orders[0].Name" value="Some name"> <input type="date" name="orders[0].Date" value="09/08/2014"> <input type="time" name="orders[0].Time" value="5:16 AM"> ... <input type="hidden" name="orders[1].ID" value="2"> <input type="text" name="orders[1].Name" value="Some name2"> <input type="date" name="orders[1].Date" value="09/08/2014"> <input type="time" name="orders[1].Time"...

404 when converting asp.net mvc app to angularjs

c#,asp.net,asp.net-mvc,angularjs,asp.net-mvc-4
so I have my full asp.net mvc project working which renders perfectly fine. Then I am trying to convert it to use angular for the UI and web api for the backend. In the views folder I added an index.html file with this code: <!-- * INSPINIA - Responsive Admin...

Set JQuery propeties to Image folder path in img src tag

javascript,jquery,html,image,asp.net-mvc-4
Question background: I'm trying to set two propeties of a JQuery function to an img src who's images are stored in the Images folder of my MVC site. The Issue: The following code shows the properties nextText and prevText being set to a left and right .jpg I have in...

Get selected data

c#,asp.net,asp.net-mvc,asp.net-mvc-4
I already have the SQL Statement for retrieving data from the database, but I dont know how to pass the value from the class that I made to the controller and lastly to the view itself. I have tried to call the method for retrieving data from the database from...

Delete Confirmation Window

jquery,asp.net-mvc,asp.net-mvc-4,telerik
<div id="modalWindow"> <button id="yes" class="k-button">Yes</button> <button id="no" class="k-button">No</button> </div> <script> var wnd; $(document).ready(function() { wnd = $("#modalWindow").kendoWindow({ title: "Delete confirmation", modal: true, visible: false, resizable: false, width: 300 }).data("kendoWindow"); }); function DeleteItem(e) { e.preventDefault(); var grid = this; var row = $(e.currentTarget).closest("tr"); wnd.center().open(); $("#yes").click(function() { grid.removeRow(row);...

Conflicted with the REFERENCE constraint. How to solve this?

asp.net-mvc-4,nhibernate
I catch this GenericADOException exception but some unexpected exception comes again when I do genRep.Update(userW). How can I fix this problem? This is my code: public ActionResult DeleteUser(long? UserID) { GenericRepositoryV2 genRep ; if (!SecurityService.IsLoggedIn(Session)) { return SecurityService.LoginAndRedirect(Request); } try { genRep = new GenericRepositoryV2(); genRep.StartTransaction(); User user = genRep.GetById<User>(UserID);...

How to get started with Visual studio 2012

c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,visual-studio-2012
I want to create web application using Visual Studio 2012. The application should login into a website and report numerical findings on the UI. The language used will be Visual C#. I have loaded the application and selected on the menu: File> New > Projects. A window appears with multiple...

Jquery: Change contents of