.net

MVC Validating Strongly Typed Views

I have following ViewModel: public IEnumerable<SelectListItem> SelectAdminsInGroup { get; set; } public IEnumerable<SelectListItem> SelectAdminsNotInGroup { get; set; } public model.Admin Admin { get; set; } Admin class: [PropertiesMustMatchAttribute("Password","ConfirmPassword")] public class Admin { public ...

How to stop Silverlight upgrading between point release automatically

I have a Silverlight application. The application was compiled with version 4.0.x. Today the application has told me that we need to upgrade to a newer version of 4.0. We don’t want to upgrade to the newer version as we will need to do it on all our client machines. Is there any way we can get our application to use the older version of ...

Why has the overloaded Add been replaced with AddWithValue?

The overloaded method SqlParameterCollection.Add(String, Object) has been marked as deprecated since version 3.5 SP1 of the .NET Framework. You should use the AddWithValue() method that was introduced with version 2.0. Is there a good reason why the Add(String, Object) has been replaced with a AddWithValue()? I'm fine with the change, b...

Windows Forms: DataGridView Binding Question

I have a Winform DataGridView, which has a number of predefined columns. Now I have an array of objects (the object structure conforms to the defined gridview columns) and I want to bind the gridview to this array (with gridview.datasource = array) The problem is now, that I get several new columns in the grid after the predefined colum...

Are there any better ways to copy a native dll to the bin folder?

I have C# wrapper code that calls functions from a native (C++) dll. Currently, I can add a reference to the C# dll and have set the 'Copy Local' option to true. However the native dll, which is a dependency, cannot be added as a reference - so there is no 'Copy Local' option. I have tried the following approaches Using a post-build ...

What's the recommended approach to generating a Preview Thumbnail Image of the fist page of a FlowDocument

I would like to generate a small Preview Image of the fist page of a FlowDocument (imagine a Thumbnail View of a collection of FlowDocuments). Can anyone recommend a good approach for doing this? ...

IComponentChangeService events don't fire when Property Value is modified

I am working on a WinForms designer hosting project. All controls that will be dropped on the DesignSurface are custom controls that inherit from existing controls. My DropDownListControl: [Serializable] [ToolboxBitmap(typeof(System.Web.UI.WebControls.DropDownList))] [ListControlSerializerAttribute("asp", "DropDownList")] public clas...

register for an event in Windows

Hi I want to do something when a memory stick attached to PC. Now I use a timer and check it in every tick whether any memory stick is plugged(use DriveInfo or with querying WMI) Is there any event driven model available to do? for example i use an event in my program that raise whenever a memory stick is plugged in to computer? ...

Regex, I need to improve a method to get src and alt from an image

There is no problem to get the src or alt separately,but how can get both at the same time every one with a group name. We have to bear in mind that alt can be to the left or right of src. I am in a hurry, so I found a quick solution, creating 3 groupnames for the src, and and for alt. I know we can do it a lot better. private voi...

LINQ - how to make change tracking work when entity passed to another class as property

Here's the scenario: I have an ASP.NET user control that runs a LINQ query, stores the results in a generic List, then dynamically loads another user control (into a Placeholder) and passes one of the objects from the List to the control through a property on the control. The child control displays data from the object and allows the u...

Use of SPListCollection.Add Method (String, String, String, String, Int32, String, SPListTemplate.QuickLaunchOptions) in sharepoint

How to use of SPListCollection.Add Method (String, String, String, String, Int32, String, SPListTemplate.QuickLaunchOptions) for creating sharepoint document library programmatically using asp.net? or Can you plz show me steps for creating document library programmatically/dynamically using asp.net in Itemadding event? Thanks in advance...

System.IO.Path.GetTempPath() access denied

Hi, im creating temporary files to be stored in the Temp folder found by: string path = System.IO.Path.GetTempPath() method returns C:\windows\Temp\ i append my filename: string filename = myfile.txt System.IO.Path.Combine(path,filename) However, this gives me a "Message":"The given path\u0027s format is not supported.","StackTrac...

Migrator.Net - create from existing database

We are thinking of starting to use Migrator.Net and I was wondering if there is any way of creating/importing the existing schemas and creating the class files. It would be a lot of work to create them all by hand, but in all my searching I can't seem to find anything that will do this. ...

Line Chart for .NET prior framework 3.5

I am developing an application and I must do it in WPF and use .NET 3.5. The problem is that I can't use MSCharts for 3.5 because that would require XP installations to install SP3, something that they don't want. The WPF toolkit was buggy on their machines, so is there any other solution or I should start just drawing lines? ...

Only allow access to action if redirected from specific action

Hi Is there a good way to restrict the access to an action, so you can only access it, if you were redirected from another action. For example: [HttpPost] public virtual ActionResult Create(MyViewModel vm) { if (ModelState.IsValid) { // do some work return RedirectToActio...

Converting VB6 Custom Type (with Fixed Length Strings) to VB .NET

I have upgraded some VB6 code, which uses fixed length strings in custom types, to VB .NET by using the UpgradeWizard and am having trouble with the use of the LSet method that I was hoping someone could help me out with. The Existing VB6 code (type declarations); Public Type MyType PROP1 As String * 15 PROP2 As Str...

Scheduling in my web apps

Hi there, i'm writing a web app in C# in which i need to implement a scheduling function which has to be fired every day at the same time, i already used quartz to do something similar in an JEE application and it works perfectly; reading some post and docs about using quartz.net gave me some doubts how to implement it. How can i inte...

C# Class Inheritance

I am working with insurance and have two different policy types - motor and household, represented by two different classes, Motor and Household. Both have several bits of data in common, so both would inherit from another class called Policy. When a user logs into the app, they could have either a motor or a household policy, so the a...

C# dll that can be pinvoked?

Question: Is it possible to write a C# dll that can be pinvoked ? I want to write a replacement library for the WinAPI calls WritePrivateProfileString etc. for reading and writing ini files. Is it possible to export a function, e.g. 'WritePrivateProfileString', implemented in C# so one can pinvoke the dll with DllImport ? I want to re...

"Microsoft JScript compilation error: Expected ';'" Invoking ASMX Web Service

I have a very simple ASP.NET web application created under Visual Studio 2008 (SP1), targeting .NET 3.5. Startup page is a dumbed down ASPX page with 4 text boxes, a button, and two JScript functions: An OnLoad handler for the body. This function just sets the values of the text boxes to certain dates and times for testing. An OnClic...