Posts by Tiago César Oliveira • 2,855 points
74 posts
-
1
votes1
answer58
viewsQ: How to turn a UNIX timestamp into Datetime?
I have a date field in the format UNIX timestamp, and I need to turn this field into a DateTime of C#. How to proceed? Example of input: 1514959643539 Desired output: DateTime with correct date/time…
c#asked Tiago César Oliveira 2,855 -
1
votes1
answer58
viewsA: How to turn a UNIX timestamp into Datetime?
The class System.DateTimeOffset has appropriate methods for handling UNIX timestamps in a C#development environment. We can do the desired transformation with the code below (the code was created to…
c#answered Tiago César Oliveira 2,855 -
2
votes1
answer122
viewsA: Where for Inner Join
The SQL syntax would be something like this: select login, nome_hotel from extranet_login ext_log inner join extranet_hoteis ext_hot on ext_hot.id_login = ext_log.id_login inner join hoteis hot on…
-
1
votes2
answers1023
viewsA: Collect dropdown menu with Javascript
I recommend you use the event mouseleave to control such behaviour: $(function() { $('li').on('click', function() { $(this).toggleClass("active"); }); $('li').on('mouseleave', function() {…
-
2
votes2
answers64
viewsA: Why can’t I query for an added object before Savechanges?
Well, in SubItem = repositorioSubItem.Buscar(e => e.Valor1 = 1); you are sending search in context for an item that is not there, since the SaveChanges() not yet executed. This results in a query…
-
2
votes1
answer1794
viewsA: Only get user name in AD
The code below (rode in a console application) does the split that you need and returns the user: using System.Security.Principal; string user =…
-
0
votes2
answers94
viewsQ: Continuous integration TFS/Azure and Connection string in app.config
I have a project composed of two subprojects, one of those subprojects is a Class Library, responsible for database connection activities. I am using Entity Framework as a ORM tool. In the archive…
-
1
votes1
answer128
viewsA: controller responsibility
To solve this kind of question I usually create a layer of data access (Dal) and create in it the features that access data. Following this model, we would have your classBancoDAO (Data Access…
asp.net-mvc-5answered Tiago César Oliveira 2,855 -
2
votes2
answers1465
viewsA: Automatic date field fill in application
If Data_Retorno must at all times be 5 days longer than Date_Inicial, calculate this in the method executed in POST of your controller: [HttpPost] public void Index(string nome, DateTime…
-
-1
votes4
answers440
viewsA: Right menu in each Row of a table
Simply remove :first-child in menu: $(document).ready(function () { $("table").contextmenu({ delegate: "tbody tr", menu: ".table tbody tr .skills" }); }); Jsfiddle updated…
-
1
votes2
answers1045
viewsA: Question with multiple school in Jquery
EXAMPLE IN JSFIDDLE In a very simple way: HTML <form> <label><input type="radio" name="q1" value="1" />Resposta 1</label> <label><input type="radio" name="q1"…
jqueryanswered Tiago César Oliveira 2,855 -
5
votes2
answers311
viewsA: How to check if it is a URL in input text?
To adhere to the provisions of RFC 3987 (governing the guidelines for defining Urls), the following regular expression can be used for validation:…
-
2
votes2
answers372
viewsA: return view with empty model
Use RedirectToAction: return RedirectToAction("Novo");
asp.net-mvc-5answered Tiago César Oliveira 2,855 -
0
votes3
answers301
viewsA: Css selector syntax to delete <td> element with jQuery
Your dial is almost correct. For the HTML markup below <table id="tabela"> <tr> <th>Linha com TH</th> </tr> <tr> <td>Linha com TD</td> </tr>…
-
2
votes3
answers760
viewsA: How to close mysql connections in C#
Mysqlcommand.Beginexecutenonquery performs a form instruction asynchronous in relation to the database. This means that the query is not executed as soon as the command is given, but at the most…
-
3
votes2
answers492
viewsA: Mount Datatables with Repeater
You are very attached to the component syntax. This can be solved with a simple link. Instead of <td> <asp:LinkButton ID="LinkButton1" runat="server"> linkButton</asp:LinkButton>…
-
2
votes1
answer41
viewsQ: Maintenance and recovery of service Urls
I am working on a Web Forms project that has a DLL, and in this DLL there are references to external services. We have 3 environments (development, homologation and production) and for each…
-
2
votes2
answers1647
viewsA: How to position html elements with css
Use a grids system, such as Twitter Bootstrap. Following is an example of a form using the grids system of the same: <form class="form-horizontal" role="form"> <div class="form-group">…
-
4
votes1
answer123
viewsA: How should I communicate with DB? Technology recommendations
Development for mobile platforms is usually based on tools already available on other platforms (usually web). Thus, mobile solutions are nothing more than new interfaces for the same application,…
-
5
votes1
answer51746
viewsQ: Align multiple Divs horizontally within a container
I have several div with float: left inside another div, which is their container, according to code: <div id="container"> <div id="box-1" class="box">1</div> <div id="box-2"…
cssasked Tiago César Oliveira 2,855 -
4
votes1
answer51746
viewsA: Align multiple Divs horizontally within a container
To get the desired result, I needed to understand what elements with float escape the page rendering flow and become independent elements (within limitations of position, margin, padding, etc.). To…
cssanswered Tiago César Oliveira 2,855 -
8
votes3
answers1415
viewsA: When should I use elements '<ul>'?
The semantics of HTML is something that makes sense (mainly) for search engines, which are based on the semantic structure of their code to perform the correct rankings. Naturally, obeying the…
-
3
votes3
answers2113
viewsA: Application that does not need to load full page
Example calling the PartialView Listagem Controller public class Home { public ActionResult Listagem() { return PartialView(); } } Javascript With jQuery: $.ajax({ type: "GET", url:…
-
3
votes2
answers623
viewsA: Doubt on how to select a record via Inq
Use models and return them in your LINQ query. Model public class Script { public string TipoScript { get; set; } public string Script { get; set; } } LINQ consultation var resultado = from s in…
-
3
votes2
answers2098
viewsA: Browse the entire DOM with jQuery
For your need I would do so: <li menu="home" class="home" data-target="submenu"><a href="#">Home</a></li> Note the attribute data. From there on: $(".home").on("click",…
-
3
votes1
answer110
viewsA: When I run my WCF REST enters the WCF Client Test screen
Why are you running from your file .svc. Run from any other file to get debug in browser. In short: if you run (debug or not) being in the file .svc, the WCF Test Client window is displayed. Note…
-
2
votes2
answers1040
viewsQ: Null check returns reference error
Model public class Transacao { [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int ID { get; set; } [Required] public DateTime Data { get; set; } [Required] public decimal…
-
2
votes2
answers1040
viewsA: Null check returns reference error
The error is in the way the model instantiation is occurring. In our controller, we must create an empty reference in the variable transacao: var transacao = new Transacao(); And, in view…
-
6
votes4
answers4178
viewsA: What is the difference between joining tables by JOIN and WHERE?
In relation to performance, both equalize. However, note: SELECT * FROM clientes c, enderecos e We forgot the clause WHERE linking the keys to the tables. The result is a Cartesian product. Use JOIN…
-
5
votes2
answers3464
viewsA: Secure authentication via REST
Since one of the rules of the REST standard is Um protocolo cliente/servidor sem estado, your request must contain all what is necessary to understand the request - which includes authentication.…
-
3
votes1
answer9340
viewsQ: Check if the given value is numerical and has 9 characters
How can I verify if a value is numerical, and only numerical (without occurrence of points, strokes, etc.), regardless of the amount of characters that the number contains, besides having exactly 9…
-
6
votes1
answer9340
viewsA: Check if the given value is numerical and has 9 characters
It is possible to get this information using the mask ^\d{9}$ in a regular expression, which in addition to checking the amount of characters ({9}), checks if they are numerical (\d): string valor =…
-
18
votes4
answers20028
viewsQ: Detect if an element contains a class with pure Javascript
In jQuery, we have the code $("#elemento").hasClass("nomeDaClasse"); Which indicates if an element contains a certain CSS class. How can I achieve the same with pure Javascript?…
javascriptasked Tiago César Oliveira 2,855 -
8
votes4
answers20028
viewsA: Detect if an element contains a class with pure Javascript
Your element has the property className which contains all classes linked to it. From there, you can create a simple Javascript function to detect if an element has a CSS class: function…
javascriptanswered Tiago César Oliveira 2,855 -
1
votes3
answers3981
viewsA: Declare variable within my cshtml
It makes no sense to feed a server side variable at runtime without running a postback. By the way, this is not even allowed, you would have to run your server side part to get it. The best way…
-
3
votes2
answers330
viewsQ: Display layout only when view is not loaded via ajax
In my project, I am developing so that the application works even if the user is with Javascript disabled or unavailable. If Javascript is not available, I load the page normally. If available, I…
-
1
votes1
answer398
viewsA: Web API 2 - Use of Reasonphrase in exception handling
Well, apparently the tip from Gypsy Morrison Mendez is correct, I did a small test using the JS below: $.ajax({ type: "GET", url: 'api/teste/?id=1', contentType: "application/json; charset=utf-8",…
-
1
votes1
answer398
viewsQ: Web API 2 - Use of Reasonphrase in exception handling
var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = "Nenhum produto encontrado" }; throw new HttpResponseException(resp); That code should return 404 No products found But…
-
0
votes2
answers462
viewsA: How to make "new" notification equal to Gmail?
All messages have one status, and it controls the way messages are displayed (a simple replace of CSS classes). In the case of ajax requests, yes, they do exist, but are executed periodically. Gmail…
-
3
votes1
answer1350
viewsA: How to send emails using Javascript?
You can use the API of Mandrill for this. It is free for the first twelve thousand monthly shipments. You would make calls to the API with simple HTTP requests. The easiest way would be using jQuery…
-
4
votes1
answer1270
viewsA: Is it safe to use ajax requests over and over again?
Everything will depend on the standard size of your answer and the performance of the query. The ideal is to traffic only the data that will be consumed. You can, for example, pass in each request…
-
5
votes2
answers3276
viewsA: How to make a Stored Procedure dynamic by taking data from other tables in the database?
You can use cursores. DECLARE a INT; DECLARE cur CURSOR FOR SELECT i FROM test; OPEN cur read_loop: LOOP FETCH cur INTO a; //Operações END LOOP; Cursor is a powerful feature of Dbms. However, it can…
-
4
votes2
answers231
viewsQ: Removing comments in the HTML sent by the server
We all know the good old HTML comments: <!-- Oi, eu sou o Goku! --> The point is: there is some way to delete HTML comments that the server sends to the client? I think such configuration is…
-
4
votes2
answers1169
viewsA: Save form data in session
Sessions are ways to store data that will be deleted when a given event occurs (in the default behavior of ASP.NET, when 20 minutes have passed since the user’s last action, or when the browser…
-
2
votes2
answers5943
viewsA: Convert row to column
You need to perform a PIVOT. In other databases, such as SQL Server, it is easier to do this. In Mysql you need to create aggregated expressions, as for example the one I created in Sql Fiddle, take…
-
4
votes1
answer264
viewsQ: Specific application of attribute [Childactiononly]
I saw from the ASP.NET MVC documentation that the use of the attribute [ChildActionOnly] prevents the method from being called directly via GET, only through a specific view. Frankly, I don’t…
-
17
votes6
answers11947
viewsA: How to create a password reset link?
You should not store passwords that can be recovered. Use one-way algorithms like the one implemented by BCrypt (option I use in my projects). This means your password 12345 becomes something like…
-
4
votes3
answers380
viewsA: What is the importance of certification?
A certificate is (for the market) a way of proving that you have determined knowledge, rather than imposing on the contractor the burden of discovering and verifying it. Of course there are these…
certifiedanswered Tiago César Oliveira 2,855 -
4
votes1
answer1352
viewsA: Error: subquery returning more than one result
If you want to make a DELETE in all fields of the subquery, do so: DELETE FROM wgcartarmazens WHERE artigo IN ( SELECT artigo FROM wgcartarmazens as T JOIN wgcartigos as A ON A.CODIGO = T.ARTIGO…
-
2
votes1
answer240
viewsA: How to leave textarea and button next to each other?
Can be implemented with calc. Jsfiddle textarea { width: calc(100% - 60px); } button { position: fixed; right: 0; top: 0; width: 60px; }…