Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
1
votes2
answers147
viewsA: Problem with a Count in Asp.Net MVC
Even though it is a screen behavior, it is important not to leave the Action decrease vacancies that do not exist: [HttpPost] public ActionResult Inscricao(int inscricaoId) { using (var scope = new…
-
6
votes1
answer282
viewsA: Relationship between different contextual classes Entity Framework
There is no. It’s not just the design definition that matters in the Entity Framework: for all relationships and mappings to work properly, they need be defined in the same context. It doesn’t make…
-
12
votes3
answers4902
viewsA: How to load a dropdown with a selected value
The most succinct way to write this is like this: <select name="selPeriodo" class="form-control"> @foreach (var item in @ViewBag.Periodos) { <option value="@item.Id" @(Model.PeriodoId ==…
-
2
votes2
answers179
viewsA: Photo saved in Directory does not appear in Solution Explorer
It is both normal and great that the photo does not appear in Solution Explorer, because the files that appear in Solution Explorer are files from the project. Incorrect would be if photos that do…
-
2
votes1
answer74
viewsA: Attach many objects with id = 0
The problem is very similar with this reply, in which the questioner makes the same mistake, but does not deserve to be treated as duplicated because, in your case, the answer deserves further…
-
1
votes1
answer92
viewsA: How to bar the registration of an already registered user
Not much of a secret, really. Just the verification of AlunoCurso: [HttpPost] public ActionResult Inscricao(int inscricaoId) { using (var scope = new TransactionScope()) { //Aqui eu pego o Aluno…
-
3
votes2
answers305
viewsA: Only constructors without parameters and initializers are supported in LINQ to Entities - Asp.Net MVC
Avoid doing things like this in your code: return View( db.Cursos.Select(c => new CursoInscricoes( c, db.AlunoCursos.FirstOrDefault(ac => ac.Aluno.Equals(aluno) && ac.Curso.Equals(c))…
-
0
votes1
answer157
viewsA: How to configure Web.config in Cordova project?
Define in your Web.config the following: <configuration> ... <appSettings> ... <add key="BaseURL" value="http://localhost:12345/" /> </appSettings> </configuration>…
-
0
votes2
answers1431
viewsA: Make a program in c# that runs online
The latest technology for building Web solutions in C# is called ASP.NET MVC. There are some tags for it here on the site, such as Asp.net-mvc, Asp.net-mvc-4 and Asp.net-mvc-5. You can see the…
-
5
votes1
answer406
viewsA: How to map a TIME-like column in Entity Framework 6?
The guy is TimeSpan. Just make sure that you use at least SQL Server 2008, which is the first version of SQL Server that supports the guy time: public TimeSpan IntervaloMaximoAlmoco { get; set; } To…
-
0
votes1
answer595
viewsA: Button only work if you pass the ID in the URL in Asp.net MVC
Basically, you are using an Ajax request whose method is POST, but you’re not passing data by POST. Change to the following: @section Scripts { @Scripts.Render("~/bundles/jqueryval") <script>…
-
0
votes1
answer139
viewsA: How to link an Id to Asp.net MVC
As I explained to you here, how modeling has changed, what needs to be done is to create an object of association between Aluno and Curso and then decrease the amount of vacancies of a Curso. That…
-
1
votes1
answer267
viewsA: Get data from a column in the database for a variable
If I understand, just need to use String.Format(): fundo.registerLog(String.Format(Resources.MensagemSucessoImportacao, logDescription));…
-
0
votes1
answer359
viewsA: Listing on Asp.Net MVC
The modeling is incorrect. As it stands, a Curso belongs to only one Aluno. The correct is to create an associative table. I suggest something like this: public class AlunoCurso { [Key] public int…
-
1
votes1
answer108
viewsA: SQL database for multiple users
If most queries performed within the system will involve the user parameter, yes, you will need to parameterize all tables with the Id user, because it is a design requirement of the Entity…
-
2
votes1
answer541
viewsA: Customizing Individual User Accounts
First of all, it is important to read this answer so that we have a starting point. For the purpose of this response, I have managed a new project with Individual User Accounts. It’s a good starting…
-
2
votes1
answer643
viewsA: How to connect to the Azure Database?
Log in to Azure; On the database part, choose the desired database; Choose the option "Manage"; Azure will tell you that you need to add a Firewall exception to your IP and ask for confirmation.…
-
2
votes2
answers971
viewsA: Form single field validation in Asp.Net MVC
Implement a Attribute cpf: namespace MeuProjeto.Attributes { [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] sealed public class CPFAttribute :…
-
3
votes1
answer1406
viewsA: Disable a button on Asp.net MVC
Here’s a huge problem: <td> <div class="btn-group"> <div class="col-md-offset-2 col-md-10"> <a href="@Url.Action("Inscricao", "Curso")"><input type="submit"…
-
0
votes1
answer149
viewsA: customize Roleprovider without using Membership or ASP.NET Identit
Apparently the implementation code is ok, but there is something weird in the configuration. You are using parameters from MembershipProvider to set up a RoleProvider. I would do so:…
-
0
votes3
answers220
viewsA: Return in a view-specific div
If I understand how Scrollspy works, it rolls alone for a certain <div> by clicking a button when the document is ready ($(document).ready()). The validation information is generated by a…
-
3
votes2
answers1346
viewsA: How to login to WEB project Asp. Net MVC No Authentication?
As a simpler and less demanding answer, it would be better to generate another solution with Individual User Accounts and transfer the sources of the old solution to the new solution, but it is…
-
4
votes2
answers298
viewsA: Convert Linq query to Dapper
It is a simple spacing problem. If using concatenation of String, always try to put a gap between sentences and. This piece: "where c.AnoVigencia = @anoVigencia and" + "c.FilialId = @filialId and" +…
-
6
votes5
answers11991
viewsA: How to validate and calculate the control digit of a CPF
How the algorithm that calculates the digit of a CPF works (Cadastro da Pessoa Física brasileiro)? As Wilson Neto response, there is an explanation on this link. Module 11 is basically applied in a…
-
4
votes1
answer1024
viewsA: Query user data logged in Windows Authentication
I wrote a Helper (a static class with static methods) with a method that locates users of a domain with their information and another that details a specific user: using MeuProjeto.ViewModels; using…
-
2
votes1
answer54
viewsA: Relationships Does EDMX only affect performance?
That’s it much wrong the way you use it. Entity Framework without foreign keys makes no sense from any point of view. Answering your question, yes, and much. If there are no foreign keys, there are…
-
3
votes1
answer763
viewsA: Displaying Modal with model passed inside a C# Asp.net MVC foreach
From what I understand, all modals have the following construction: <!-- Modal --> <div class="modal fade" id="comentario" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"…
-
1
votes1
answer119
viewsA: How do MVC application authentication with Linux?
The error occurs because you added the Entity Framework to your project in an irregular manner. The correct is to add it per package. Open the Package Manager Console (View > Other Windows >…
-
1
votes1
answer42
viewsA: Problem with ASP.NET website administration tool!
Add the following user to the directory C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files: Done this, try to set up again.…
-
0
votes1
answer566
viewsA: Select file without using Openfiledialog
From what I understand, the code loads a digital certificate using an environment variable (in this case, the variable indicating where the desktop is). The file name is on label1. Therefore, it is…
c#answered Leonel Sanches da Silva 88,623 -
0
votes1
answer163
viewsA: Search email in the database by name
Just formatting the answer already provided in question with some modifications, such as opening and closing the Connection outside the for: int numclientes = listBox2.Items.Count; cn.Open(); for…
c#answered Leonel Sanches da Silva 88,623 -
5
votes3
answers1631
viewsA: How to add Directory to the Windows Path variable during installation?
You can write an app that does this in C#: Using Environment.SetEnvironmentVariable: var originalPath = Environment.GetEnvironmentVariable("PATH"); Environment.SetEnvironmentVariable("PATH",…
-
1
votes1
answer98
viewsA: MVC 5 template or other: initial user form, information, database
I had to adjust the original question to answer because the question made no sense, given the author’s original doubt. I will keep the answer with the original version and the amendments below for…
-
4
votes1
answer522
viewsA: Entityframework 6 + Lazyloadingenabled + using()
If you are having a lot of work, it means you are using the wrong tool, and this is evident from your explanation. I guess I won’t be able to get tired of saying Entity Framework is already a…
-
0
votes2
answers576
viewsA: @If inside a <body> tag
Try using the ternary operator similar to the second form: <body @{Request.Path.Substring(Request.Path.LastIndexOf("/") + 1).ToLower() == "default" ? "class='home'" : "";}>…
-
3
votes1
answer94
viewsA: How to fire an event when a List is changed?
Yes, but not using exactly List<>. Use instead ObservableCollection<T>. Basically, the class has two events that do what you need, but you would only use CollectionChanged for all three…
c#answered Leonel Sanches da Silva 88,623 -
0
votes1
answer45
viewsA: System.Invalidoperationexception Database Opening Error?
Substitute: var db = Database.Open("Northwind40.sdf"); For: var db = Database.Open("UmaConnectionStringVálida"); I don’t know what database technology that object Database uses, but possibly this…
-
2
votes1
answer93
viewsA: Onselectionchanged MVC
First of all, I think it’s worth knowing how jQuery works. The correct for your case is this Bundle here: @Scripts.Render("~/bundles/jquery") I don’t know what your logic is, but a start would be…
-
1
votes1
answer33
viewsA: What mistake is that?
Possibly your Webgrease and your Microsoft.AspNet.Web.Optimization are out of date. You can update from the Visual Studio panel: Or via command, via Package Manager Console: Update-Package…
-
2
votes1
answer482
viewsA: ASP.NET Identity and Web API - Problem to register new user
This problem is not very easy to solve because the error message does not help much. Actually the source of the problem is here: registerDomain.UserName = registerDomain.Email; By default, the user…
-
3
votes1
answer643
viewsA: Problem with Decimal (4,2)
I would make a Binder special to decimal places: public class DecimalModelBinder : IModelBinder { public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {…
-
2
votes1
answer1324
viewsA: C# Image and PDF Manipulation
Using the iTextSharp 4, can be done as follows: iTextSharp.text.Document Doc = new iTextSharp.text.Document(PageSize.LETTER, 20, 20, 20, 20); string PDFOutput =…
-
2
votes1
answer967
viewsA: Update to remove a piece of a varchar field
Very simple, in fact: UPDATE TABELA SET COLUNA = REPLACE(REPLACE(COLUNA, '//', '/'), 'http:/', 'http://'); I made you a Fiddle. See more about the REPLACE here.…
-
0
votes1
answer123
viewsA: Decrease in a field of table Asp.net MVC
I’m guessing you’re using Entity Framework to abstract the database. An example of Action in the Controller it would be something like that: public ActionResult Inscrever(int id) // Este id é o id…
-
2
votes1
answer103
viewsA: Virtual store domain forwarding
Yes, it is possible. Only to get a good response, you need to know what HTTP server technology we are dealing with. The technique is simple and is based on your DNS records: having the domain…
redirectinganswered Leonel Sanches da Silva 88,623 -
2
votes1
answer425
viewsA: EF6 Entityvalidationerrors error in filled property
Your Model is wrong. The navigation property: public virtual PublicacaoBlog Publicacao { get; set; } Can’t be decorated with [Required] because she will not be saved. What is right is PublicacaoId…
-
1
votes1
answer32
viewsA: Utlizar SMO in SSMS
It is possible to use SMO as a substitute for SQLDMO within SSMS (SQL Server 2008 R2 version)? According to Technet, the SQLDMO feature has been removed from SQL Server 2012 onwards. The SMO feature…
sql-serveranswered Leonel Sanches da Silva 88,623 -
3
votes1
answer357
viewsA: Hide a column from a Webgrid
I have never used this component, but there is a constructor that can be used like this: WebGrid obj = new WebGrid(Model, columnNames: new[] { "ID_PARAMETER", "CD_PARAMETER", "DS_CONTENT",…
-
1
votes3
answers7469
viewsA: ASP.NET Trust Level
According to Locaweb Wiki, the setting can be at most for Medium Trust: <configuration> <system.web> <trust level="Medium" /> ... </system.web> ... </configuration>…
asp.netanswered Leonel Sanches da Silva 88,623 -
16
votes3
answers12225
viewsA: What is deadlock in SQL Server?
Deadlock is not a unique database concept, but competing applications. In a nutshell: It is a situation where two or more competing actions are each waiting for the other to end, and therefore this…
sql-serveranswered Leonel Sanches da Silva 88,623