Posts by Tobias Mesquita • 22,900 points
750 posts
-
4
votes1
answer147
viewsA: Make calculation using LINQ
as you gave more details about your database schema or your entity mapping, so it is difficult to deliver something more optimized. Then try the following query.: var entradas = from entrada in…
-
3
votes2
answers165
viewsA: How to select elements that have a valid id?
you can use the following selector: [id][id!=''] var elems = $("[id][id!='']"); console.log(elems); <script…
jqueryanswered Tobias Mesquita 22,900 -
-1
votes2
answers1620
viewsA: Fix column of an HTML table
The easiest way for you to freeze the first column of the table using Bootstrap, is to add the datatables to your page and start your table with fixedColumn = true. var source =…
-
0
votes2
answers16529
viewsA: Cannot set Property 'innerHTML' of null
its code has some errors, besides trying to access elements that do not exist, as "#veiculos", is trying to access elements outside its scope. Below is a reworked version; var Cadastro = function ()…
-
3
votes2
answers68
viewsA: Simplify the use of multiple Places all
You can transform the string into an object using the JSON.parse, then you can take all the keys of the object using the method Object.key(), finally just go through the keys with a forEach. In the…
-
3
votes1
answer316
viewsA: Unique authentication for multiple projects using Entity Framework
first step is to have a cookie single for all projects, for such, edit your web.config and assign the same name to the Authentication Cookie. <authentication mode="Forms"> <forms…
-
1
votes1
answer538
viewsA: Passing data field parameters
First, try not to assemble the query by concatenating the parameters, even if there is no risk of SQL Injection, but SQL Server will not be able to save the query execution plan. Second point, using…
c#answered Tobias Mesquita 22,900 -
1
votes1
answer26
viewsA: Text Infinity Rotator
at this point, instead of interrupting the flow, restart the value of current_word if(current_word >= words.length -1) { //stop! we're done return; } then we’ll have this.: if(current_word >=…
javascriptanswered Tobias Mesquita 22,900 -
2
votes2
answers232
viewsA: Inheritance with Entity Framework
first, if Usuario should not have all fields of Pessoa, soon he should not inherit from person. In your case, the most interesting approach is to make a 1-1 relationship with Usuario and Pessoa, but…
-
1
votes3
answers1279
viewsA: Is there any way to make a div son, float while rolling the scroll of the father div?
you can use the event scroll as mentioned, but the top value should take into account the initial 50. Below follows an example. Modernizr.addTest('csscalc', function() { var prop = 'width:'; var…
-
1
votes1
answer82
viewsA: Leave a fixed option on a dynamic table - JS
store the value of the select in the localStorage, when loading the page, update the value of select and call the event change. var dynamicTable = (function() { ... })();…
-
0
votes1
answer53
viewsA: Adjust CSS on browser-independent page
if all you want is to center the element on the page, then a value in px to the top and the left is not the best option. then try to use the following css: top: 50%; left: 50%; transform:…
-
3
votes0
answers62
viewsQ: use Sqldependency with [ORM]
I am developing a service that must perform a procedure whenever a record as a certain condition is entered in the database. However, despite using the SqlDependency, I’m not using the SqlCommand,…
-
1
votes1
answer68
viewsA: Error in Javascript variable
you are trying to access a variable that does not exist in your current scope. you are to declare rdIdem inside function rdDesIdemRem(), so it is only accessible within this function. when trying to…
-
5
votes1
answer2422
viewsA: Move Image with Javascript
you can and should use CSS for this. html, body { position: relative; width: 100%; height: 100%; padding: 0px; margin: 0px; } img { position: absolute; width: 128px; height: 128px; animation: move…
-
2
votes2
answers662
viewsA: Convert HTML as image
The easiest way for you to achieve this is by using an external utility, in case the WKHtmlToImage. To do so, you will need to write your HTML on disk, using the System.IO.File.WriteAllText(string…
-
3
votes2
answers286
viewsA: format value with javascript
you can do so: var format = function (format, text) { var array = text.split(""); return format.replace(/{(.*?)}/g, function (index) { return array.splice(0, index.replace(/\D/g, "")).join(""); });…
-
1
votes1
answer62
viewsA: Javascript function is only working with 1 or 2 variables
I tried to reproduce your current scenario based on your example posted in the comments. Handlebars.registerHelper("inc", function(value, options) { return value + 1; }); var data = [ [3, 5], [6,…
javascriptanswered Tobias Mesquita 22,900 -
3
votes2
answers1533
viewsA: How to bring the typed data and store it in a json to do the processing afterwards?
you can serialize your form with the help of Formdata.: var serialize = function (form) { var json = {}; var data = new FormData(form); var keys = data.keys(); for (var key = keys.next(); !key.done;…
-
2
votes2
answers401
viewsA: Get element position based on another
From my point of view, it would be x: 20 and y: 10, since there is a displacement of 20px na horizontal and 10px na vertical. in whatever way, you can use the method getBoundingClientRect to take…
-
0
votes3
answers388
viewsA: View images side by side using Javascript/Bootstrap
You have here two options, modify the Bootstrap Carousel to support multiple frames. You can use the implementation of the following Codeio for this. The second option is to use Slickjs or another…
-
2
votes1
answer757
viewsA: ASP.NET MVC & WEB API token authentication
Your problem is not with the ASP.NET Identity or with the ASP.NET MVC, but when trying to serialize the Entity proxy Usuario. This Proxy is created so that it is possible to perform the LazyLoad in…
-
1
votes2
answers206
viewsA: Is it possible to optimize this javascript code?
PS.: I took advantage of some concepts presented by Bacco in the above Answer. The first thing you need to do, is store the date of the event and the coordinates of it, then you will have an object…
javascriptanswered Tobias Mesquita 22,900 -
3
votes3
answers528
viewsA: How to compare indexes of two objects and return what is different?
for objects, you can do as follows.: Object.defineProperty(Object.prototype, "except", { enumerable: false, value: function (outro) { var keysB = Object.keys(outro); return…
-
1
votes1
answer438
viewsA: Inserting duplicate data into Javascript Array (push)
Your problem is simple, but first I want you to look at the following code snippet.: //define um unico array vazio. var elementos = []; $('p').each(function(){ //obtem o valor selecionado. var…
javascriptanswered Tobias Mesquita 22,900 -
5
votes2
answers520
viewsA: Taking the total in pixels of an element passed in variable in percentage
You don’t need JavaScript to maintain the ratio between Width and Height, if you want to keep the Height commensurate with Width, set the Height with vw (viewport width). If you need Width to be…
-
7
votes1
answer1062
viewsA: Is there a way to create a parallel run using javascript?
Yes, it is possible using Web Workers. The code to be executed on a separate Thread must be in a separate file, it will receive the contents of the main thread through the event onmessage and will…
-
18
votes5
answers1106
viewsA: Is SOAP safer than REST?
As for security, I see only one difference between REST and SOAP. In REST, security is only done in the transport layer, whether using SSL or TSL. SOAP also gives you this option. But following the…
-
4
votes4
answers961
viewsA: how to generate an xml in memory
Can I give you a hint, don’t mount the XML in your hand. You can and should define a contract as the below.: [DataContract(Name = "mensagemSNGPCInventario", Namespace = "urn:sngpc-schema")] public…
-
2
votes3
answers566
viewsA: Same types but with different objects. What is the best way to use it?
I come here to add an alternative, which may be useful if the class has a circular reference and you have domain over it. You can decorate it with the attribute [DataContract] and [DataMember] and…
-
4
votes3
answers449
viewsA: Alignment of text vertically
remembering that the property top, left, right and bottom are referring to the parent element, so to have the expected behavior, this must occupy the entire page.: html, body { position: relative;…
-
3
votes1
answer271
viewsA: What’s the difference between the two select?
Matheus, your doubt is not necessarily about ASP.NET MVC, but about Entity Framework but could be applied to whatever ORM. LINQ I would say that most of the time, you should opt for LINQ, be it…
-
1
votes1
answer788
viewsA: Running a Method in the background Asp.Net/C# (Async or Thread)
I see that all you need to do is fire an event and forget, so the async/await is not the best option, after all the await will wait for the return. You can achieve the expected result as follows.:…
-
2
votes1
answer1189
viewsA: Graphics with HTML and CSS
Carlos, although it’s possible to do it from scratch, you can use d3js as a starting point for your graphics. Take an example: var data = [ {"key":"Stream #0","values":[…
-
5
votes1
answer83
viewsQ: Allow Multiple Users per Browser
For example, the Google allows you to maintain n accounts of Google wrinkled in your browser. In the case of Google, it creates a call control variable authuser who receives a inteiro, it passes…
-
1
votes1
answer30
viewsA: Function to send data to the database after a while
to schedule an execution, you can use the window.setTimeout, to send the data to the server, you can use the XMLHttpRequest or the $.ajax. var dados = { prop1: "Hello", prop2: "World" }; var tempo =…
-
0
votes1
answer29
viewsA: Is it possible to make an appendTo for another document?
I will start from the premise that both pages belong to the same domain, but will not necessarily be opened in the same tab. in the list page you can do something like.: var testeConteudo =…
-
1
votes2
answers341
viewsA: Stop an ajax request and create a new one
Leo, the $.ajax returns an object of type jqXHR, and for reasons of compatibility it maintains some methods and properties in common with the XMLHttpRequest, among them the .abort(). var jqRequest =…
-
1
votes1
answer35
viewsA: Javascript event repeats itself in other Ids
Fabio, your problem is in the name of tag <p>, she’s getting something like demo+10 rather than demo10. The second point, you’re declaring myTimer on the global scope, so with each interaction…
-
3
votes1
answer1256
viewsA: How to format`Datetime? ` in dd/mm/yyyy format using Linq?
This is not possible as the Entity cannot translate the ToString(format) for a function Sql, Then it will be necessary to execute the query without formatting the date, only then format the date.…
-
8
votes2
answers359
viewsA: Optimize foreach
I have no way to test, but try the following LINQ (but I doubt it will be faster than one). var lista = from checkBox in pendenciaController.ListaCliente join pendencia in…
-
7
votes2
answers421
viewsA: Group css selectors to reuse code
use class for this.: .tipoPokemon span { text-transform: uppercase; font-weight: bold; font-style: italic; } .tipoPokemon span#fire{ color: red; } .tipoPokemon span#water{ color: blue; } if you…
-
1
votes4
answers1757
viewsA: Empty input cannot receive zero
as you said is wearing a mask jQuery to format the value and add the R$, then you must be using the jQuery MaskMoney. So the first thing to do is to use the method .maskMoney('unmasked') get all the…
-
1
votes2
answers49
viewsA: Prevent Seed from duplicating data
Fabio, for Addorupdate to work the right way, you need to inform the fields you will use to make the comparison, and your entities need to have these fields declared.: So you have two options.: 1.…
-
3
votes2
answers1377
viewsA: How, after a POST request, to receive JSON feedback on C#?
Although Virgilio’s reply is correct, I’d like to suggest a few changes. First, the class HttpClient implements the interface IDisposable, then initialize it using the block using(). The await…
-
2
votes3
answers682
viewsA: How to mount a lambda expression and pass it by parameter to a Generic function?
You want to make it simple and flexible or complicated and cast? using (var context = new MyWonderfulRepositoryContext()) { dgUsuarios.DataSource = from pessoa in context.Pessoas where /* minha…
-
5
votes2
answers2458
viewsA: What is the purpose of Transactionscope blocks?
Goku, since your question makes use of Linq to SQL, then I will consider only transactions involving Database and will disregard transactions with instated objects. So, to get the good use of a…
-
8
votes2
answers213
viewsA: Treat return in class in C#
you can set a custom get;set;. public class Mesa { public int Cdmesa { get; set; } public int Flsituacao { get; set; } public string Status { get { switch (this.Flsituacao) { case 1: return "LIVRE";…
-
0
votes2
answers492
viewsA: How to format date in firefox
Panchester, you can make a module with a Feature Detection (in case, to check if the browser supports the input[type='date']). var DatePicker = (function () { var DatePicker = function (element) {…
-
0
votes4
answers1129
viewsA: Last Child of Element Chain
you can search the element by class. var containers = document.querySelectorAll(".container"); [].forEach.call(containers, function (container, indice) { var teste =…
javascriptanswered Tobias Mesquita 22,900