.net

ValidationSummary with Client Side & Server Side Validation

Hey, If you use a CustomValidator control and a ValidationSummary control within an aspx page for server side validation you can set the ErrorMessage of the validator and its Text value will appear in place and the ErrorMessage value will be displayed within the ValidationSummary control. Nice. Now, what if I also perform validation o...

Programmatically scroll DataGridView to last row after setting it's DataSource

I've got DatGridView bound to BindingSource and I'm trying to scroll it to the bottom after setting it's DataSource. Binding source's MoveLast() make's last row selected but it doesn't scroll down. I've tried to set FirstDisplayedScrollingRowIndex, but it throws InvalidOperationException with a message "No room is available to display...

Can I call stream.Close from another thread ?

Can I safely close a System.IO.Stream (or any of the wrappers or Readers) from a second thread? I've a new System.IO.StreamReader(inputStream, Encoding.ASCII); reading from network, and am considering shutting it down from another thread by closing it. If this is not a good idea then what's another way of forcing the thread blocking in...

How to serialize an object in C# and prevent tampering?

I have a C# class as follows: public class TestObj { private int intval; private string stringval; private int[] intarray; private string[] stringarray; //... public properties not shown here } I would like to serialize an instance of this class into a string. In addition: I will be appending this string as a Qu...

How do I validate email address formatting with the .NET Framework?

I want a function to test that a string is formatted like an email address. What comes built-in with the .NET framework to do this? This works: Function IsValidEmailFormat(ByVal s As String) As Boolean Try Dim a As New System.Net.Mail.MailAddress(s) Catch Return False End Try Return True End Function ...

Why does OracleParameter implement ICloneable but doesn't provide Clone()?

I am using the OracleClient library version 1.0.5000.0 and I am confused about the OracleParameter class and its implementation of ICloneable. This is the definition of the OracleParameter class: public sealed class OracleParameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable { public OracleParameter(); public O...

Decode encoded html to display in SIlverlight

I have text I am displaying in SIlverlight that is coming from a CMS that is used to store web content. There are fields in the cms like name and description that contain html tags and encoded characters. What is the best way to convert/strip these from the text so they can be displayed in a silverlight textblock I am leaning towards r...

Use *.pdf’s in class library project (web)

Hi, I have some pdf's templates that are being used across many web applications. Can I add pdf's files to dll project? Thanks J ...

Replace nested ForEach with Select if applicable

Is it possible to replace method ForEach() usage with Select() or something else to write next code in one string with nested extension methods? OR maybe there are another ways to improve the algorithm? var list = new List<IStatementParser>(); System.IO.Directory.GetFiles(path, "*.dll") .ForEach(f => System.Reflection.Assembly.Load...

How to have userfriendly names for enumerations?

Hi, I have an enumeration like Enum Complexity { NotSoComplex, LittleComplex, Complex, VeryComplex } And I want to use it in a dropdown list, but don't want to see such Camel names in list (looks really odd for users). Instead I would like to have in normal wording, like Not so complex Little complex (etc) Also, my applicat...

Why I cannot inherit LinkedListNode<T>?

In .NET 3.5, I am using the LinkedList class but I am having the following issue. I want the items of that list to be aware of the previous and next items in the list. In other words, I want the method in the items to be able to do this.Next, this.Previous. Is this possible? Below is an example of what I would like to do. Day d1 = new D...

Approach for n-tier CRUD applications in .NET

Here’s a really really super-basic question. Say I wanted to build – today – an enterprise CRUD application in .NET that had an n-tier architecture. What data access approach should I use? I want interoperability, so DataSets are out (and I suppose it’s not 2003 anymore, either). Likewise, .NET RIA Services’ advertised method of expo...

How do you transform a upn name to a login name?

How do you transform a upn name like "[email protected]" to the corresponding NT account name, which is frequently "EXAMPLE\user"? In the domains I'm familiar with, I can take the first part after the '@' sign, but I'm concerned that this is not guaranteed to be correct. Do I have to run an ldap query? Would it be a property on the use...

Enum type constraints in C#

What is the reason behind C# not allowing type constraints on Enum's? I'm sure there is a method behind the madness, but I'd like to understand why it's not possible. Below is what I would like to be able to do (in theory). public static T GetEnum<T>(this string description) where T : Enum { ... } ...

Distributing microsoft.visualstudio.texttemplating.dll with custom app

We are writing an app that will use T4 to generate Flex/Actionscript to compile into SWF. We would like to distribute this app to users who will not have VS. I've searched and searched and could not find any info anywhere on redistributing microsoft.visualstudio.texttemplating.dll with your apps, except on this code plex project (http://...

How can I display a symbol in a string with c#?

I have a string that I want to display a symbol in (the division symbol you learn in elementary, not a slash). According to the character map, the font that I'm using to display the string (inkpen2) has a division symbol code of 0xD4. I want a string to be "5 symbol 7" and display it to the user. Is it possible to do this? ...

Control without a form in VB .Net

I would like to make an application where there is no form, only controls, this way theuser can see what they are doing on top of their work. How could I for instance put a textbox on the screen, just like form1, but without it being a parent of form1, almost as if it was form1. Basically form1 is hidden. Thanks ...

Dynamic interception of calls in .NET

I am curious to learn if .NET supports any form of dynamic interception of method calls (or properties invoctions) at runtime. That is, can you intercept a call to an object without static compilation information such as an interface (along the lines of the CORBA DII (link text) or COM's IDispatch). If not, would the new 'Dynamic Typed ...

How can I display a negative symbol in .NET?

I want to display a negative symbol from a string in .NET. I want a string that represents an equation that looks something like this: 7--5=12 But when displayed, I want the 2nd minus sign to be slightly raised so it looks more natural as a negative sign instead of just 2 minus signs in a row. Is this possible? ...

.Net Listbox DataBinding Problem

I have a main class which creates and populates a DataSet and an instance of this class is then passed to sub controls of my application by reference. I want to use this dataset to databind to components, in this case, a listbox. This is for a windows forms application. Heres what I'm trying: channelTypesLB.DataBindings.Add("Text", syn...