Posts by BrunoLM • 5,198 points
81 posts
-
2
votes1
answer605
viewsA: How to catch div through another class
For an HTML tag to be visible in code-Behind you need to put the attribute runat="server", otherwise only visible on the front end. You can mix HTML tags with ASP.NET tags. The difference is that…
-
1
votes3
answers4043
viewsA: How to add a CSS class to images that didn’t load?
For new elements inserted dynamically it is possible to do using the MutationObserver. And for the other images just get them and add the event. var observer = new MutationObserver(…
-
5
votes3
answers1977
viewsQ: How to delete a file marked with the "Read only" attribute?
I am trying to delete a file that is marked with the attribute "Read only": Whenever the file is marked with the said attribute, I get the following exception: System.Unauthorizedaccessexception was…
-
0
votes3
answers1977
viewsA: How to delete a file marked with the "Read only" attribute?
To remove read-only you need to remove this attribute. For this you can use the class FileInfo. var info = new FileInfo("teste.txt"); And access the property Attributes that is Enum with flags (read…
-
9
votes2
answers2594
viewsQ: What does it mean and how does an Enum work with the [Flags] attribute?
I was seeing how the class works FileInfo and came across an Enum: [Serializable] [ComVisible(true)] [Flags] public enum FileAttributes { ReadOnly = 1, Hidden = 2, System = 4, Directory = 16,…
-
5
votes2
answers2594
viewsA: What does it mean and how does an Enum work with the [Flags] attribute?
An Enum with this attribute allows you to put multiple values into a single variable. For example: var atributosDoArquivo = FileAttributes.ReadOnly | FileAttributes.Hidden; The Enum marked with the…
-
9
votes2
answers282
viewsQ: Is there a way to save types not listed in Settings.Default?
In a Windows Forms application I can create configuration properties. However there is the type List<T> or Dictionary<TKey, TValue>. By clicking on "Browse" and searching on mscorelib…
-
13
votes4
answers6231
viewsA: How to select a text snippet in a String?
With that expression /<#(.*?)#>/ You can capture the text between <# and #>. To get all the match you need to use it as follows: // cria um objeto RegExp com a flag global var regex =…
-
1
votes1
answer158
viewsQ: How do I test Htmlhelper, Ajaxhelper and Urlhelper methods?
I wrote some extensions for the MVC helpers. The problem is that I don’t know how to test these methods since I don’t have these objects in a test unit. How do I test the methods I created?…
-
1
votes1
answer158
viewsA: How do I test Htmlhelper, Ajaxhelper and Urlhelper methods?
To get these helpers you need to instantiate them. One practical way is to have a class with static properties, so you can quickly get a helper in the context of your test. public static class…
-
4
votes3
answers249
viewsA: How can I manipulate a PSD file to get the position of the layers?
The Paint.NET can handle PSD files. With the DLL Photoshop.dll, I managed to manipulate the PSD file: using PhotoshopFile; One problem is that transparent layers don’t exactly take up the space I…
-
2
votes2
answers3614
viewsQ: How do I convert the size of a file into bytes for KB, MB, GB, TB, etc?
I’m picking up the file size to display on the screen: new FileInfo(arquivo).Length Only this property returns me the total of bytes... I would like to display in a format that I could understand,…
-
1
votes2
answers3614
viewsA: How do I convert the size of a file into bytes for KB, MB, GB, TB, etc?
There are several ways to do this. One that caught my attention was the deepee1 method. I made a small adjustment and put this method in a class of Extension methods. public static partial class…
-
3
votes1
answer304
viewsQ: Why does keybd_event not work in some contexts?
I want to understand why keybd_event doesn’t work in some contexts. For example, it does not work in games with League of Legends or emulated games on ePSXe. The following code: Keys key = Keys.Q;…
-
6
votes1
answer265
viewsA: How do I calculate the size of the tag source in a tag cloud?
I created some examples to clarify the delan’s response. Basically the formula is: (tagAtual.Usos / maiorNumeroDeUsos) * (fonteMaxima - fonteMinima) + fonteMinima Example in Javascript var tags = […
-
6
votes2
answers2183
viewsQ: How to set the cursor position in an editable element?
I have the following structure: <pre id="editor" contenteditable="true"> “Always pass on what you have learned.” - Yoda > {|} -- X </pre> I want when someone clicks on a button I put…
-
7
votes1
answer1780
viewsQ: How do I know if at least one element of a list is contained in another list?
I have two lists: var lista01 = new List<int> { 1, 2, 3, 4, 5 }; var lista02 = new List<int> { 7, 7, 7, 7, 7 }; I need to check if at least one element of list 1 exists on list 2, then…
-
8
votes1
answer1780
viewsA: How do I know if at least one element of a list is contained in another list?
There are some methods in Lille that can help you do this: Intersect If the result of an intersection results in 1 or more elements means that at least one is equal. var resultado =…
-
8
votes2
answers3908
viewsQ: How can I get the first element of each parent element?
I have a structure like this: <div class="container"> <span class="iconset"></span> <!-- primeiro elemento --> <span class="iconset"></span> </div> <div…
-
1
votes2
answers3908
viewsA: How can I get the first element of each parent element?
There is the selector :nth-child(). You can use by passing the parameter 1 to get these elements. I see a example in jsFiddle. var elementos = $(".container .iconset:nth-child(1)");…
-
0
votes1
answer887
viewsQ: How can I allow insertion directly into a Datagridview?
I am setting the DataSource of a DataGridView with a List<T>. I enabled by designer "enable addition". But there is not appearing that line with asterisk for adding new elements. My code is…
-
0
votes1
answer887
viewsA: How can I allow insertion directly into a Datagridview?
The problem is you’re trying to put a List<T> in the DataSource, however a list does not have the resources to connect the screen component with the property. Instead of using a List<T>…
-
4
votes3
answers249
viewsQ: How can I manipulate a PSD file to get the position of the layers?
I am working on a project where we have a file . psd (Photoshop) called "sprites" that contains all the icons of the site. I would like to get the positions of each layer to automatically generate a…
-
4
votes1
answer265
viewsQ: How do I calculate the size of the tag source in a tag cloud?
I have a cloud of tags and want to change the font size of each tag as you use them. I need to have a minimum size and a maximum size. What would be the formula to calculate tag size?…
-
9
votes2
answers399
viewsA: How to show value of an attribute in content: of a pseudo-element?
CSS yet does not have a way to access attributes of a parent element. However it is possible to obtain an attribute through attr(), documented here in English. content: attr(title); This way the…
-
5
votes2
answers399
viewsQ: How to show value of an attribute in content: of a pseudo-element?
I want to show the value of an attribute as text. <div title="12:56pm"> <span data-measureme="1"> <span>hi</span> </span> </div> Example that doesn’t work in…
-
3
votes2
answers3847
viewsQ: Is it possible to assign the default value of a property with an attribute?
I wish I could declare a property as: [DefaultValue(10)] public int Maximo { get; set; } And when I was going to use it, it already came with the value started in 10. However the attribute does not…
-
3
votes2
answers3847
viewsA: Is it possible to assign the default value of a property with an attribute?
The attribute DefaultValue, as stated in the specification, by itself does not change the value of the property. It serves to be used by the design editor and code generators. It is possible to use…
-
2
votes8
answers14487
viewsA: How to create a copy of an object in Javascript?
An isolated copy of the method extend jQuery would be like this: First a function is needed to see if the object should be cloned or not // para evitar loops infinitos o jQuery clona apenas objetos…
-
6
votes1
answer681
viewsQ: Letter after a number, what is this called?
What’s the name of it? double d1 = 0d; decimal d2 = 0L; float d3 = 0f; And where can I find a reference of the characters I can use? If I want to make one cast of 0 for short, there is some letter…
-
2
votes1
answer954
viewsQ: How do I convert a Datatable to a dynamic object?
How can I convert a DataTable in a IEnumerable<dynamicObject>? For example, I want to convert any DataTable ID | Name DI | emaN --------- ou --------- 1 | x 2 | x 2 | y 1 | y In a list of…
-
1
votes1
answer111
viewsQ: How to check if one control is the son of another? "Control.Ischildof"
I have 3 panels: <asp:Panel ID="ParentPanel" runat="server"> <asp:Panel ID="AnnoyingPanel" runat="server"> <asp:Panel ID="P" runat="server"> </asp:Panel> </asp:Panel>…
-
1
votes1
answer111
viewsA: How to check if one control is the son of another? "Control.Ischildof"
You can use a Extension method recursive like this: public static bool IsChildOf(this Control c, Control parent) { return ((c.Parent != null && c.Parent == parent) || (c.Parent != null ?…
-
4
votes2
answers670
viewsQ: What is the equivalent of Usercontrol in ASP.NET MVC?
In Web Forms we have UserControl. These controls have a code-Behind and a layout. They can be used in different projects/solutions without depending on other things. I want to create a control that…
-
2
votes1
answer1256
viewsQ: How can I run Javascript (most current possible) in C#?
First I tried to run with a control WebBrowser WebBrowser webBrowser1 = new WebBrowser(); webBrowser1.Visible = false; webBrowser1.Navigate("about:blank");…
-
1
votes1
answer1256
viewsA: How can I run Javascript (most current possible) in C#?
You can run Javascript with Phantomjs. For this it is necessary to invoke it using Process. try { Process p = new Process(); ProcessStartInfo psi = new ProcessStartInfo("phantomjs.exe",…
-
6
votes1
answer3199
viewsQ: What does <T> mean in . NET?
I’m working on a project and I saw a lot of code like this public class ExemploCollection<T> { ... } And I don’t understand what this <T> means. What’s the name of it, what am I looking…
-
8
votes1
answer3199
viewsA: What does <T> mean in . NET?
The context name of this is Generics, see the documentation. T is not a reserved word. T, or any other given name means "type parameter". See the following method: T GetDefault<T>() { return…
-
14
votes3
answers30199
viewsQ: How do I round numbers to the nearest integer?
I have numbers double as double a = 0.4, b = 0.5; How do I round it up?
-
3
votes3
answers30199
viewsA: How do I round numbers to the nearest integer?
To static class Math contains methods for rounding numbers: Use Math.Ceil to round up Math.Ceil(0.5); // 1 Use Math.Round to round, in this method you can enter a second parameter to determine…
-
8
votes2
answers2862
viewsA: How do I turn my computer off, restart, sleep programmatically?
To manage operations as is I created a class to call the methods of external Dlls: public class WinPower { [StructLayout(LayoutKind.Sequential, Pack = 1)] internal struct TokPriv1Luid { public int…
-
7
votes2
answers2862
viewsQ: How do I turn my computer off, restart, sleep programmatically?
I would like to add these options in a program, after finishing a task the computer would be shut down/restart/put on Sleep. How can I do that?
-
3
votes3
answers3264
viewsA: Invert the order of a jQuery widget list
I thought of another way to implement this, treating as a kind of stack. Example in jsFiddle. Stack First I need to store the elements in a variable. var elements = $("li"); In this way the elements…
-
2
votes7
answers4242
viewsA: How to reset CSS formatting?
I know two ways, one of them is a well known and discussed reset /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html, body, div, span, applet, object,…
-
4
votes2
answers230
viewsA: How to avoid animation of elements that will not fit in the width of the screen?
Just modify the CSS by removing float and aligning vertically to the top, updated example: http://jsfiddle.net/BzuR2/1/ #balls > img { display: inline-block; margin-left:28px; vertical-align:…
-
2
votes2
answers340
viewsA: ASP.NET pages continue to run after page changes?
When you pass true in the second parameter it calls the Response.End that causes an exception. And according to the documentation This is more damaging to performance than passing false (or…
-
2
votes7
answers25439
viewsA: How to convert a JSON response to a C#object?
Datacontractjsonserializer There is also the DataContractJsonSerializer, that requires the properties of a class to have the attribute [DataMember]. This class can be serialized with the…
-
2
votes7
answers25439
viewsA: How to convert a JSON response to a C#object?
Using Dynamic It is possible to extend a DynamicObject to obtain the values as follows: public class DynamicJsonObject : DynamicObject { private IDictionary<string, object> Dictionary { get;…
-
5
votes2
answers879
viewsQ: How can I prevent a user from submitting the same form multiple times?
I have a form on a page, sometimes users can double-click the button to submit the form... The form is a @using (Ajax.BeginForm(...)) { } How can I prevent that from happening?…
-
19
votes7
answers25439
viewsQ: How to convert a JSON response to a C#object?
I’m making a request and getting a JSON like this: { "id": "1000000000000000", "name": "BrunoLM", "first_name": "Bruno", "last_name": "X", "link": "http://stackoverflow.com/users/340760/brunolm",…