.net

LINQ's pathetic handling of composite keys

I have a table that has a composite key that consists of two int fields and one varchar(50) field. I made the composite key my primary key, which I don't usually do. Yes, yes, yes, I'm more than familiar with the logical key vs. surrogate key debate, but I must have done some heavy drugs (not really) the day that I made the table since I...

ASP.NET ListView full row select

So I am playing around with using a ListView instead of a GridView to accomplish a complicated goal. The ListView is helping in a lot of ways, but there is one particular bit of code I am used to using with GridView's that won't doesn't work with ListView's. If I have to have a nice mouse hover action on my rows in a GridView, and if I ...

alternative in .Net to building Tables/TR/TD manually?

I've got a pile of code here that looks like this: if (stateTax > 0) { tr = new TableRow(); tbl.Rows.Add(tr); td = new TableCell(); td.CssClass = "stdLabel"; td.Text = "NY State Tax"; tr.Cells.Add(td); td = new TableCell(); td.Text = string.Format("{0:C}", stateTax); td.CssClass = "justRight"; tr...

Shorter Binding expression with validation

Hi, I'm repeating same binding parameters for every textbox and they're quite long strings (which is not good for many reasons). And I'm wondering if there's a way to make them shorter? For instance all my controls on forms are using the following binding template: Text="{Binding SourceProperty, UpdateSourceTrigger=PropertyChanged, Va...

How do I select the shallowest matching elements with XPath?

Let's say I have this document. <a:Root> <a:A> <title><a:B/></title> <a:C> <item><a:D/></item> </a:C> </a:A> </a:Root> And I have an XmlNode set to the <a:A> element. If I say A.SelectNodes( "//a:*", namespaceManager ) I get B, C, and D. But I don't want D because it's nested in another...

What is the order of execution when dealing with .NET MVC 2 Action Filters?

Say I have: [Attribute1(Order=0)] public class Controller1 { [Attribute2] [Attribute3] public ActionResult Action1() { ... } } The attributes get executed in the following order: 2, 3, 1 This makes sense because attributes 2 and 3 have an order of -1 and will be executed before attribute 1 which has an explici...

Can I use handwriting personalization in custom .net app

Windows Vista and 7 both contain the ability to personlize the handwriting recognition. You can train the tablet to recognize your specific style. I know the personlization is used by the Native Windows Tablet Input Panel (TIP), the OS's handwriting control. Does the .NET SDK provide access to this personlization data so that my ....

Parser Error C:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe

Getting this error not sure what is wrong Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Cannot execute a program. The command being executed was "C:...

Transparent graphics surface in VB.NET?

Hi, I am making an application in VB.NET that allows a user to highlight some text in images of documents so that the highlights could be saved for future reference, but the original images would not be modified. I figured I can achieve it by creating a graphics out of an image file and allowing the user to draw on that graphics. The pro...

How set timeout on XDocument.Load(string uri)?

Is there a way to set a timeout on System.Linq.Xml.XDocument.Load(string uri)? Or should I use the technique described in http://stackoverflow.com/questions/299198/implement-c-generic-timeout? ...

Adapt text validation function to consider selected text

I have this function which evaluates the contents of a textbox (or combobox or maskedtextbox) control and, in conjunction with a KeyPress event, will either allow or disallow the input. It is quite useful for dates or textboxes for which only numeric input is valid. It allows a set number of digits after a single decimal point, if spec...

How does the App_LocalResources work with MVC?

I've been working through my first MVC application, and I'd like to localize it. I know how to use the App_GlobalResources but I'd prefer to use the App_LocalResources. In a typical WebForms application, you put the App_LocalResources folder in the same directory as the ASPX file... is this the same in MVC (IE: do I put them in the res...

Gradient Drawing Bug

I'm having trouble with a gradient drawing call. I have a Form that looks like this. The problem is every now and again the above gradient drawing bug will start happening. It should go right across of course. Sometimes it only takes some build-rebuild-mashing to fix and it'll simply just "start" after a build every now and again. Th...

.net Components ... a Custom Form

Hi, I've been working in the creation of some custom components adding functionalites to the basic components such as a Datagridview. Now I want to create a custom Form ... I mean, when I choose add new item in the VS menu, there is a Windows form and some varians of it like an about box, or Dialog, that are simple Forms with a custom ...

Trying to cast a boxed int to byte

Code to illustrate : int i = 5; object obj = i; byte b = (byte)obj; // X When run, this generates a System.InvalidCastException ("Specified cast is not valid") at line "X". Doing a double cast works : byte b = (byte)(int)obj; I would have thought that you ought to be able to cast a boxed int (if it ...

Reading lines from a .NET text/scintilla box without using too much memory?

I have to create a C# program that deals well with reading in huge files. For example, I have a 60+ mB file. I read all of it into a scintilla box, let's call it sci_log. The program is using roughly 200mB of memory with this and other features. This is still acceptable (and less than the amount of memory used by Notepad++ to open this...

Do subdomains have a part in cross-browser restrictions when calling webservices from Javascript?

Hi guys, The scenario is this: My html page is on http://www.mydomain.com/somepage.html Using jQuery, I call a webservice on: http://subdomain.mydomain.com/webservice.asmx/somemethod At the moment this is not working. I suspect that the subdomain is breaking a x-browser restriction. Any ideas? It is working locally when the html p...

Display strings from array in a textboxes that are in different xaml WPF

Hello! So, I got a 10 element array and I want to display those elements in a 10 textboxes that are in different xaml file and are created as a child of stack panel. How do I do it? Thanks in advance. ...

c# Thread issue using Invoke from a background thread

Hello - I've got thread, which processes some analytic work. private static void ThreadProc(object obj) { var grid = (DataGridView)obj; foreach (DataGridViewRow row in grid.Rows) { if (Parser.GetPreparationByClientNameForSynonims(row.Cells["Prep"].Value.ToString()) != null) Upda...

Measuring memory usage in .Net

I'm trying to get a program I'm writing (in F#, though I would imagine the answer here is the same for any CLR language?) to report on its own memory usage (so I can get an idea of how much I'm stressing the machine, compare sizes of different workloads, and evaluate the effect of any optimizations I do in the hope of saving memory). Th...