.net

Reg Expression in C#

Hi All, <add key="Key1" value="Provider=SQLOLEDB.1;data source=serveripaddress;Initial Catalog=DB1;user id=uid;Password=***"/> I gave the above string,I want to get the serveripaddress,DB1,uid and **** these values from that string. ...

How to set AutoCompleteExtender to allow only values from autocompletion list?

Hi, Does anybody know how using AutoCompleteExtender (from AJAX Control Toolkit) prevent user from entering anything not in suggested values? ...

msbuild builds always debug

I am trying to build release mode . like that msbuild LP.sln /p:buildmode=release Blockquote but i get always debug . any idea why ? I saw and checked following posts . link text link text thanks a lot . ...

How to encrypt a string in .NET?

I have to encrypt/decrypt some sensitive information in a Xml file? Yes I can do that by writing my own custom algorithms. I am wondering if there is already a built in way in .NET to do that and also what points I always need to take care.. ...

Search keyword highlight in ASP.Net C#

Hi all, I am outputting a list of search results for a given string of keywords, and I want any matching keywords in my search results to be highlighted. Each word should be wrapped in a span or similar. I am looking for an efficient function to do this. E.g. Keywords: "lorem ipsum" Result: "Some text containing lorem and ipsum" Des...

Listview insertion mark invisible when there's groups

Update: (Please vote to close) This question is unresolved, and is likely a list view bug. It can be replicated by using the example code from the MSDN link below, and adding this code after the list view initialization code: myListView.View = View.Details; myListView.Columns.Add("Column1"); myListView.Groups.Add...

Automapper Mapping

I'm trying to map an object with property names like so: Property_One -> PropertyOne ... etc Sample_Property -> SampleProperty Is there a better way to do this than to map individually each property to another? The only difference is the underline. ...

Static (Shared in VB.NET) or Normal Methods

Hi, I Want to know which one is preferred while coding to use Static Methods or normal instances, I prefer to use static if they where few but if there was many of them I start to get some doubts Ex EmployeeCollection EmpLst = EmployeeManager.GetAllEmployees(); Or EmployeeManager EmpMgr = new EmployeeManager(); EmployeeCollection E...

Is there a way to force cast int to enum when that int does not represent a valid enum value?

enum Answer : int { Yes = 1, No = 2 } Answer answer = (Answer)100; It throws, but I don't want it to. How? ...

C# - Find output

Hi All, I have the following C# code below. Object first = 5; Object second = 10; second = first; Console.WriteLine(first + " " + second); Object a = 3; Object b = a; a = 6; Console.WriteLine(a + " " + b); I get the following output: 5 5 6 3 Actually I am expecting "6 6" as the second set. Can anybody explain where ...

Validation to allow single space for phone numbers

i have a validation in my .net textbox where it will take only numbers but when i put the the phone format like 080 234234 it will not accept because of a space how to resolve this ? could anyone help in regular expression ? Current expression is this [0-9]+ i want only single space ... no two spaces should be encoraged ...

Whats better: Deserialise to Object vs Just Xpathing against an XML Doc?

I've been doing alot of XML processing in C# of late and after coming back to C# from a long stint javascript coding I'm really missing some of the nice short cuts of JS. I've go a sizable XML document made up of lot so elements, child elements, etc. Representing Accommodations/Flights/Attraction tickets for an online booking. So far I...

A few questions before trying out .Net

Hello Before checking out what it's like developping in .Net, I have a few newbie questions: Can a non-admin user install the .Net framework, whether the original package or any subsequent update required to run a programm? Some of our customers have locked-down XP/Vista hosts, and I'm concerned about installing/updating their compute...

.Net DataGridView "Index 0 does not have a value."

I am having trouble with a DataGridView. I have a collection of 3 Items bound to the grid, when trying to delete one of the items and reload the grid. If have code of If (dlg.ShowDialog() = DialogResult.OK) Then 'Show dialog with grid on it End If On the opened dialog, I delete an item from the grid (which should in turn, delete...

.NET XSD Documentation Generator

Hi, I'm looking for an XSD Documentation Generator for .NET. Please, provide any references. Note: If it is available with source code that would be much better choice. Thanks. ...

What's wrong with this DataTable while SqlBulkCopy-ing from an Entity?

I know the method below isn't meant to work with any Entity, and its use shouldn't be enforced. I found a System.Data.Linq.Table extension method which uses SqlBulkCopy to insert data. I am trying to adapt it to the Entity Framework but it throws a strange exception, while the original works for Linq-To-Sql data classes. I couldn't find...

Is there any open source project similar to the django admin, but in .NET?

I would like to know if there exists some reusable/pluggable modules which implement CRUD operations on users, groups, roles and permissions available to be integrated in .NET web applications. ...

How to deserialize or recover a binary serialized dictionary that's not finished serializing?

When I used my app, on close, it tried to serialize a dictionary that's 300 KB. Because of no disk space, it could only write 292 KB. Is there a way to successfully deserialize whatever is in there? I used BinaryFormatter and if I lose some elements that's way better than losing the whole dictionary. When I deserialize I get this excep...

Can I implement a generic type and pass it a type that is known only at runtime?

I'm pulling serialized data from a database along with an object type (where one field contains the object type and one contains an XML string of serialized data). I've got a generic serializer that has a serialize and deserialize method: public static class Serializer<T> { public static string Serialize(T objectData) { } publi...

Can I make my service keep Windows from going to sleep?

I have a Windows service that needs to run on a PC that is left on 24 hours. I can't rely on the PC having sleep/shut down disabled because it is something being installed on around 3500 sites and X, Y or Z might mean that sleep/shut down is not disabled. Is there some neat .NET way I can keep Windows from snoozing? Or would periodica...