FAQ Database Discussion Community


How to run javascript function in Razor MVC .net

javascript,asp.net-mvc,asp.net-mvc-4,razor
<script type="text/javascript"> @if (@Model.Invoice.InvoiceDate != null) { <text> function UTCToLocalTime(date) { var time = new Date(Date.parse(date)); var timeOffset = -((new Date()).getTimezoneOffset() / 60); time.setHours(d.getHours() + timeOffset); return time; } var date = @Model.Invoice.InvoiceDate UTCToLocalTime(date); </text> } </script> I am printing the above invoice and its open in a window....

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...

How to consume multipart/form data request in C# mvc 4 webservice

c#,asp.net-mvc,web-services,wcf,asp.net-mvc-4
I created a web service for file upload. When I call this webservice I can't find multipart-form data request. If I call this webservice without a file then it will working fine. My code is: Interface code: [OperationContract] [WebInvoke(RequestFormat = WebMessageFormat.Json, Method = "POST", ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetStream")]...

select random data from database in mvc4 C#

c#,asp.net-mvc-4
I have database. Actually,i am doing for it display 10 image newest from my database but i want to display random 10 image from database.How can i do it? public ActionResult Details(int id) { var products = db.TblProductImages.Include(t => t.TblProduct); ViewData["viewcategory"] = (from p in products orderby p.ProductID descending select...

Bind multiselect selections to list of objects

c#,asp.net,asp.net-mvc,asp.net-mvc-4
I have a view model like so: public class ListingPlanEditorViewModel { public ListingPlan Plan { get; set; } public IEnumerable<Directory> SiteDirectories { get; set; } } One property is an object of type ListingPlan here: public class ListingPlan { public int? ListingPlanID { get; set; } public int DescriptionLinesCount {...

Need to Close the div in if condition MVC View

asp.net-mvc,asp.net-mvc-4
I am trying to close a div inside the if condition which is inside a foreach loop. @foreach (var item in ViewBag.modal) { counter++; <div class="Class1"> <div class="span6"> <!-- block --> <div class="block"> <div class="block-header"> <div class="left"> @item["Topic"];</div> </div> <div class="collapsein"> @item["Desc"];</div> </div> </div> @if (counter % 2 == 0)...

Get desired html element's attribute value and set to hidden field before binding in Asp.Net MVC

c#,.net,asp.net-mvc,asp.net-mvc-4,asp.net-mvc-5
Let's say such hidden field has genereated: <input data-val="true" data-val-number="The field MemberRelationId must be a number." id="MemberRelationId" name="MemberRelationId" type="hidden" value="3"> As you seem it has a value 3. It means that, user has already set the value for this field. But, he(she) can also change this value and I must...

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...

Return MVC view while submitting serialized data(MVC, Ajax)

jquery,ajax,asp.net-mvc,asp.net-mvc-4
I am new to mvc I have this AJax and Controller, i need to return a view that say "Email Sent" for now the controller redirected me to the http://localhost:1365/?Name=as&Adress=adsads&city=a&state=as&zip=as&phone=asas&Message=a Ajax Call <script> $(function () { $("#JqAjaxForm").submit(function () { debugger; var sdata = $("#JqAjaxForm").serialize(); alert(sdata); senddata = { "daye": sdata...

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....

Submitting Form in AngularJS and MVC 4

angularjs,asp.net-mvc-4,angularjs-controller,angularjs-factory
I am new to AngulaJS, and I am trying to do as many examples as I can. I found an example online that works pretty well except for the registration part. I tried to register a user; it did not submit the form, and there was not an error message/exception....

MVC best practice for displaying static generated data

c#,asp.net-mvc,asp.net-mvc-4,razor
Question background: I have a two page MVC 4 web app. The first page's view currently has its data manually typed into the View as its static i.e nothing is being passed to the View from its associated Controller method, as shown: Index controller method: Public ActionResult Index() { return...

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"...

Use “Contains” to match part of string in lambda expression

c#,jquery,asp.net-mvc-4,lambda
I have this MVC page where I have three different "input" elements, all the same class, using the jQuery autocomplete. On any one of them I am doing this in the controller: [HttpGet] public ActionResult GetAllItemsEdit(string data, string source) { List<TextValuePair> items = InventoryControlRepository.GetAllItemsTVP(); var result1 = items.Where(item => item.Text.Contains(data.ToUpper())).ToList();...

Unable to make parent li active on click of child li with bootstrap in mvc4

c#,asp.net,asp.net-mvc-4,c#-4.0
I have search and try different method like using JQuery Helper class etc but i can't find solution for my scenario. My code is below I want Active li when i user select and page refresh <aside class="main-sidebar" style="background: #102C4B none repeat scroll 0% 0%;border-right: 1px solid #DCE1E4;"> <section class="sidebar">...

How Can ignore @ in Pattern in MVC

asp.net-mvc-4
I want write pattern to my textbox in view this textbox will hold email value but i want write RegEx but i received error because RegEx contains @ i wrote @@ but still doesn't work My Code <input type="text" name="Emails" id="Emails" class="form-control Div-heigh" placeholder="To...." required pattern="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" /> ...

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...

Jquery: Change contents of