.net

How to implement Security in .Net?

I have a security descriptor for an object. I want to get users and groups having permission on that object using that security descriptor. How to know which users are having what permissions using that security descriptor? Is it possible using ObjectSecurity or CommonObjectSecurity abstract classes? If so how to define access rules? Is ...

Increase the Width of a Dropdown List

How can I increase the width of a DropDownList in ASP.NET? ...

Cancelling databound control validating event doesn't suppress attempt to update data source. winforms, .net

I'm not getting the behaviour I would expect for a TextBox bound to an integer property in a business object. Here's what I did: (1) Set the DataSourceUpdateMode, for the TextBox to: OnValidation. (2) In the Validating event for the TextBox, set e.Cancel = True if Integer.TryParse fails. (3) Add a handler to Binding.Parse and Binding...

Need some help sorting out a major abstract pattern headache within my DAL

I've caused myself a bit of an issue with my Data Access Layer. In this particular instance, I have a table that contains potentially 5 types of 'entity'. These are basically Company, Customer, Site, etc. The type is dictated by a PositionTypeId within the table. They're all in the same table as they all havethe same data structure; Posi...

XmlReader square brackets causing reader to go to errored state

I have an XmlReader that is trying to read text into a list of elements. I am having trouble getting it to reader the text: "a [ z ]". If I try with the text "a [ z ] " (same but with two trailing spaces) it works fine. Below is an example: TextReader tr = new StringReader("a [ z ]"); XmlReaderSettings settings = new XmlReaderSettings ...

Compiling an ASPX page into a standalone program

As I mentioned here, I'm trying to generate HTML from an ASPX page inside a WinForms. I'm trying to compile the ASPX page directly into the EXE; I'd like to be able to write something like this: var page = new ASP.MyPageName(); var stringWriter = new StringWriter(); using(var htmlWriter = new HtmlTextWriter(stringWriter)) page.Rend...

Can't add value to List in C#

I'd like to add a value to a struct if (!existISDNteilnehmer(split)) { isdnObjs.Add(new ISDN() { name = split, number = "", channels = new List<string>()}); } ISDN? actualISDN = getISDN(split); if (index < ISDN_teilnehmer.Count()) { var numbers = from num in xISDN.XPathSelect...

How to read, edit and write xls files, and then export to SQL Server

I have an excel file that have the list of contacts( about 10 k of them) that I need to push into my SQL Server database. So, I am writing an .net windows program using visual studio 2008 to read the files, generate random password for each contact, and then push these information in to my SQL Server database. It was easy to handle excel...

How do I reliably detect when the mouse leaves a control?

I have a number of controls with ToolStrips containing buttons. I need to show or hide some of the buttons when the mouse enters the toolstrip. I know Mystery Meat is bad but it's what I've got to do. The ToolStrip's MouseEnter event fires when the mouse enters, but MouseLeave does not always fire when the mouse leaves. I think this ma...

Minimizing MVC memory consumption footprint

How can I minimize the footprint of a website built using MVC. My application currently runs at around 20mb, I'd like to reduce it if possible. Edit: I've switched hosts, problem solved. ...

Can't run Nunit tests on Windows 7 in Nunit-gui.exe

I recently upgraded to Windows 7 from Vista and since switching, I can no longer use nunit-gui.exe to run my tests. Every time I do, I get the following error: System.IO.FileLoadException: Could not load life or assembly 'nunit.framework. Version=2.4.1.0 Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The ...

typeof(System.Enum).IsClass == false

Founded that: typeof(System.Enum).IsClass == false It's become strange that System.Enum has also .IsValueType == false, but Reflector shows that it is really just an abstract class. System.Enum is a reference type like a System.ValueType and casting enumeration values to/from System.Enum reference caused boxing/unboxing. No surprises...

How can I add a carriage return in a text using regex?

Hi, I have a text file with multiple lines. I'll try to set a pattern to add a new carriage return in some lines of the text. This lines are like that: lorem ipsum. dolor sit amet, consectetur adipiscing elit [FIS] Donec feugiat Well, the pattern is a line followed by other which has some characters and a '[' character too. If '[' is ...

Printing a WPF BitmapImage

What's the best way to print a BitmapImage? I come from a background in System.Drawing so I was thinking about converting it to a Bitmap and then printing it, but I'm thinking there's probably a better way. Thanks! ...

How to draw triangle wave using ZedGraph?

How to draw triangle wave (symmetrical) using ZedGraph? Preferably with option to adjust period and amplitude. //Edit: the function has to be [related/based on]? x (x-axis). Something like this: for (x = 0; x <= 10; x += .005) { if (Math.Sin(x * (2 * Math.PI / period)) >= 0) y = amplitude; else y = -amplitude; ...

What elements of .NET are missing in Mono?

I mean library and syntax of C#. ...

.Net Client DLL Delivery Question

I have a .Net DLL that I created that implements a WCF client that talks to a WCF service, allowing the end-user to pipe data to the server where the service resides. I use this DLL in client programs I developed for work, but now I wish to use this .Net DLL in a web page so the client can be delivered to an end-user on the net. ASP.Ne...

Testing a [Flags] enum value for a single value

If I have an enum that's marked with [Flags], is there a way in .NET to test a value of this type to see if it only contains a single value? I can get the result I want using bit-counting, but I'd rather use built-in functions if possible. When looping through the enum values dynamically, Enum.GetValues() returns the combination flags a...

Web controls lifecycle problems: A page, a grid and a dialog (containing a dynamic control whose type depends on the selected row in the grid)

I have a web page with a GridView. The GridView contains a list of Question objects. Each Question has a QuestionType. When the user clicks on the Question control, an Ajax modal popup appears containing a Dialog custom web control. The Dialog web control is designed to encapsulate a child custom web control together with OK and Canc...

how to convert an int to a bitmask?

Is there a way to convert an int to a bitmask? example: int i = 33; should be converted to (not sure of the datatype) bool[] bitmask = new[] {true, false, false, false, false, true}; Update In reaction to most answers: I need to do this: BitArray bits = new BitArray(BitConverter.GetBytes(showGroup.HasValue)); List<String> showSt...