Posts by Barbetta • 5,587 points
191 posts
-
3
votes1
answer169
viewsA: Partialview not clicking on the default of Select2
As documented by Select2, it is necessary to start the component in its PartialView add the following code $(document).ready(function() { $('.select2').select2(); }); I’m not sure if it will work…
-
1
votes3
answers87
viewsA: ASP.net MVC error
When a post in a action of a controle that takes an object as parameter it "takes" the data through the name properties. Probably the error when saving occurs because it is not going to the filled…
-
1
votes3
answers1074
viewsA: Get object content without knowing the attribute name
You can use Reflection to take the list of all attributes of the object and then with linq select which one you want, follow example public class Carro//Classe { public int CarroId { get; set; }…
-
2
votes1
answer2568
viewsA: String size exceeds the value set in the maxJsonLength property
Usually, so much for Serialization when Deserialize I use the framework Newtonsoft of namespace Newtonsoft.Json which, most of the time, is already incorporated into the project. However, if it does…
-
0
votes1
answer27
viewsA: How to insert a value in a table copy?
In his select just you can write 1 text and it will be replicated in all lines, I did without assigning 1 value to string and indented for easy viewing INSERT INTO Cad_Espec_Teste (ORDEM,ESP_LINHA…
-
3
votes1
answer53
viewsA: Sum all results of a table and separate by day/month
It is necessary to use the group by to group the same dates: select count(*) as 'total', DATE_FORMAT(item_data,'%m/%d') as 'data' from tabela group by DATE_FORMAT(item_data,'%m/%d'); EDIT Example…
-
0
votes1
answer82
viewsA: How to change the welcome message when logging in!
To reclaim the property Name logged in user, just call User.Identity.Name using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) {…
-
1
votes1
answer380
viewsA: How to get value from an Html.Editorfor
You can do with javascript a function to take the value of @Html.EditorFor(m => m.DataDoDesligamento), create a URL and open on a page with that URL. The helper EditorFor will generate an element…
-
4
votes1
answer53
viewsA: Conversion of boolean values to numbers
Just cast the cast to int u=(1>2) print(int(u))
-
0
votes2
answers60
viewsA: Trigger with column check
The form your code is not created trigger, to create it it is necessary to specify the CREATE TRIGGER nome_da_trigger CREATE TRIGGER minha_trigger AFTER UPDATE ON minha_tabela FOR EACH ROW BEGIN IF…
-
5
votes2
answers10008
viewsA: how to remove n from a python string
With the replace is possible, just re-assign the output to the variable. minha_string = "teste \n teste" print(minha_string) print("==============================") minha_string =…
-
1
votes2
answers132
viewsA: How to change EF6 to create Datetime fields as datetime2
In his Context you can configure so that all type properties DateTime are datetime2. For that it is necessary to give one override the method OnModelCreating the code would look like this: public…
-
0
votes3
answers367
viewsA: Multiplication and sum of inputs in a site
It is possible to take the value of the variables using javascript, either by id, name or class, the last two options can return 1 array since on the screen can have more than 1 item with the same…
-
1
votes1
answer547
views -
1
votes2
answers173
viewsA: How to read only one line from a file in c#
For index line, example: string[] allLines = File.ReadAllLines(filePath); string linha1 = allLines[0]; string linha2 = allLines[1]; string linha3 = allLines[2]; string linha4 = allLines[3];…
-
3
votes1
answer352
viewsA: Field without REQUIRED is being mandatory, why?
Change in your class the field of int for int? this indicates that the field is nullable. Your class Pessoa would look like this: public class Pessoa { [Required(ErrorMessage="Nome deve ser…
asp.net-mvcanswered Barbetta 5,587 -
2
votes3
answers268
viewsA: Error when calculating a loop value
The problem is being in the second while, the highest note changes according to what it passes on loop and the student counter with the lowest and highest grade keeps adding up, I would change the…
-
0
votes2
answers78
viewsA: I want to queue numbers. Python 3.6
In python, when a string * 1 number this indicates how many times you will repeat the string em questão, its function can be like this: def ex1(): valor = input("Insira o numero: ") repeticoes =…
python-3.xanswered Barbetta 5,587 -
2
votes3
answers861
viewsA: String reading Json format for c#
To catch the json {"d":{"media":12.108320606149539,"lote":"","Opcao":[{"__type":"Model","leitura":70,"producao":1579981660130}],"sinal":"Up"}} and turns it into object you can use the following…
-
2
votes1
answer234
viewsA: Authentication bearer Xamarin
It is necessary to save the token locally, in the case of Android, this is called SharedPreferences, follows an example of how I do in my applications. First I create a folder Helpers in the project…
-
0
votes1
answer40
viewsA: Doubt about mysql query
Actually there is no problem in the query, for the data not to be duplicated it is necessary to add the distinct in the select. Among the several reasons for this to occur (Duplicated data display)…
-
2
votes3
answers655
viewsA: Controller Base Dependency Injection
When you inherit a class that has a constructor with parameters it is necessary to pass it to the base of him, that is, you need to pass the IFiltroServico in the base public abstract class…
-
3
votes1
answer771
viewsA: How to Implement Automapper 6.2.2
In version 6.2.2 mapping is done via constructor, your mappings would look like this: DomainToViewModelMappingProfile: public class DomainToViewModelMappingProfile : Profile { public…
-
16
votes1
answer4985
viewsQ: What is it and what is Odata for?
I’ve been getting a few people talking about OData, I did some research I saw some codes, but I didn’t understand some things, among them: What good is Odata? What are the advantages and…
-
0
votes1
answer41
viewsA: How to mount a message array and send to a Badrequest
If you are using WebApi can return a list of objects, follow example: Class: public class Aparelho { public int ID { get; set; } public string SN { get; set; } public string Nome { get; set; } }…
-
4
votes2
answers124
viewsA: How to organize an Array in order of Time?
You can use the method OrderBy and OrderByDescending. List<string> horaString = new List<string>() { "01:04:00", "04:04:00", "02:02:10", "03:05:00", "10:07:00", "22:20:00" };…
-
1
votes1
answer164
viewsA: Select products by PAI category, with products registered in child category
You need to get them all ids of the children who have that father to make the select. This is possible through a subselect, in the example I used the column name, but you can change the where to the…
-
4
votes1
answer486
viewsA: Integer to String Conversion
You need to convert the value. With the TryParse in addition to converting, it is possible to check if there has been success in converting as it returns a bool. private void…
-
1
votes1
answer166
viewsA: Problem with form Ubmit
You need to inform that the field is not mandatory, change your class to public class Atividade { public long? Id { get; set; } public Cliente Cliente{ get; set; } } the ? allows the field to be…
-
1
votes2
answers682
viewsA: Doubt between using composite primary key or not in the associative table
Do not generate composite key, a way to lock the insertion of duplicate items is by creating index. The code would look something like this: protected override void OnModelCreating(DbModelBuilder…
-
3
votes2
answers555
viewsA: Do not update a particular EF Asp.net mvc field
After setting the object was modified with the EntityState.Modified you can indicate properties you do not want to modify with the IsModified = false, your method would look something like this:…
-
0
votes3
answers495
viewsA: Send email asynchronously Asp.net mvc
Try with the following code: public async Task<ActionResult> MyAcation() { //Codigo de criacao do objeto message Task.Factory.StartNew(() => { var smtp = new SmtpClient();…
-
2
votes2
answers483
viewsA: How to take an object property in a Session?
You will have to do the casting of Session: @{ var usuario = (Usuario)Session["usuario"]; }
asp.net-mvcanswered Barbetta 5,587 -
1
votes1
answer1338
viewsQ: Asynchronous module or handler completed while asynchronous operation was pending
I am trying to send an email asynchronously, without waiting for the return. However when I do not use the await I get an exception in return for action. Code: public Task MissaoAvaliada(string…
-
1
votes1
answer387
viewsA: Run the Submit of a form in an element click event
For ajax request you can do so: <form name="formCreate" id="formCreate" method="post"> @Html.AntiForgeryToken() <div class="col-md-4"> <label for="txtDescricao"> Descrição:…
-
0
votes1
answer104
viewsA: Ispostback Asp.net
Try the code: If Not Request.QueryString("id") Is Nothing Then Dim QueryStrMarcacao As String = Request.QueryString("id") lblMarcacao.Text = "Marcação: " & QueryStrMarcacao End If Follow Images:…
-
1
votes2
answers429
viewsA: How to popular an object with the return of a Webapi query?
By default the . Net both in webapi and MVC brings a package called Newtonsoft.Json, with it it is possible to deserialize from json to an object and the code would look like below, but as your api…
-
1
votes4
answers440
viewsA: Multiple ajax requests using jquery
In my ajax requests I usually create a class js and there are generic methods, but by semantics I end up separating gets, posts.. Below is an example I use for Post function BaseEnviaPost(url,…
-
1
votes2
answers1193
viewsA: ASP . NET MVC 5 - Dropdownlist with Modelstate?
You can create a Viewbag with the information of Type: public ActionResult Editar(int id) { //Pesquisar projeto selecionado ProjetoDAO proj_dao = new ProjetoDAO(); Projeto proj =…
-
2
votes4
answers8025
views -
2
votes1
answer665
viewsA: Asp.net c# DDD - problem when passing data from Entity to Viewmodel
You need to map the model to viewModel. there are some libraries for this, among them the Automapper, which can be downloaded via Nuget. After Download you add a class in App_start, as below: public…