.net

How do I persist a value accross views

Completely new to asp.net mvc... completely new to web apps so bear with me... Lets say I have an Action on a controller that requires a specific piece of information, say an int Id value. A view is rendered from this Action. This view contains a button which will take the user off to a new Action on another Controller. On the view o...

Converting a int to a BCD byte array

I want to convert an int to a byte[2] array using BCD. The int in question will come from DateTime representing the Year and must be converted to two bytes. Is there any pre-made function that does this or can you give me a simple way of doing this? example: int year = 2010 would output: byte[2]{0x20, 0x10}; ...

Is Lazy<T> supported in the compact framework?

Does anyone know if the new lazy initialization class (Lazy<T>) is or will be supported in the compact framework? I've looked on MSDN, but the support stuff listed on the bottom is kind of cryptic when it comes to support for the compact framework vs. the full-blown .Net framework. ...

Updating Cells in a DataTable

I'm writing a small app to do a little processing on some cells in a CSV file I have. I've figured out how to read and write CSV files with a library I found online, but I'm having trouble: the library parses CSV files into a DataTable, but, when I try to change a cell of the table, it isn't saving the change in the table! Below is the ...

Dynamic LINQ Group By Query in ASP.NET MVC

I'm wondering how to best tackle this, since what I have now works great for a hard-coded column in my view -- I'm wondering how I can extend it to allow the column to be dynamic. CONTROLLER: var dc = new DataContextDC(); return View(dc.items.Where(i=>i.IsPublic == true)); VIEW: <% foreach (var grp in Model.GroupBy(s => s.GroupColum...

Threading heap and stack

How memory is allocated in case of spawning a new thread, i.e how memory heap, memory stack, and threads are related? I know this is fundamental (.net framework concept) but somehow I am not much aware of this concept. ...

How do you print from a popup window in javascript?

I have a .Net application that dynamically creates a small HTML page and pops it up in a new window using the javascript document.open method. Everything with that functionality is working fine. Now I want to add a button to the HTML page that prints the page. I have tried using the following code to no avail: <a href='print.html' ...

How do I deal with connection strings in a Click-Once application?

I'm thinking of building a Click-Once application, and am trying to wrap my head around how to handle the whole connection string issue. The problem is the following: I want to use EF to get data directly from each client, thus requiring each client to have a connection string configured (this is not the issue). How do I deal with clien...

Best Practise for Writing a POS System

Hi, I'm putting together a basic Point of Sale (POS) system in C# that needs to print to a receipt printer and open a cash drawer. Do I have to use the Microsoft Point of Service SDK? I've been playing around with printing to my Samsung printer using the Windows driver that came with it, and it seems to work great. I assume though that...

Is there any way, short of "copy and paste inheritence" to share a .net class with a Silverlight app?

I have a project in two parts: a Silverlight front end and a WCF duplex service. Ideally, I would like to pass a message of a custom type (call it TradeOffer) from the WCF service to be consumed by the Silverlight application. When I try to, I get an error that indicates I can't pass an object of an unknown type across the wire like tha...

How to eliminate tearing from animation?

I'm running an animation in a WinForms app at 18.66666... frames per second (it's synced with music at 140 BPM, which is why the frame rate is weird). Each cel of the animation is pre-calculated, and the animation is driven by a high-resolution multimedia timer. The animation itself is smooth, but I am seeing a significant amount of "t...

How to implement table-per-concrete-type strategy using entity framework

I'm mapping a set of tables that share a common set of fields: So as you can see I'm using a table-per-concrete-type strategy to map the inheritance. But... I have not could to relate them to an abstract type containing these common properties. It's possible to do it using EF? BONUS: The only non documented Entity Data Model Map...

How can I improve this design?

Let's assume that our system can perform actions, and that an action requires some parameters to do its work. I have defined the following base class for all actions (simplified for your reading pleasure): public abstract class BaseBusinessAction<TActionParameters> : where TActionParameters : IActionParameters { protected Base...

How to make Stack.Pop threadsafe

I am using the BlockingQueue code posted in this question, but realized I needed to use a Stack instead of a Queue given how my program runs. I converted it to use a Stack and renamed the class as needed. For performance I removed locking in Push, since my producer code is single threaded. My problem is how can thread working on the (...

Can I attach a .NET TraceListener to an externally running process?

I am developing an application scheduling program that will run other applications using System.Diagnostics.Process. The external applications are of various types (some .NET and some not). For those external apps that have trace logging enabled, is there a way that I can attach the tracelistener of the parent/calling application to li...

Session variable in WCF application

I need to use or stimulate a very simple session object inside my WCF app. I simply need to store some values at the beginning of a call and I need access to these values while I go through some different methods of my service. Asp.NET session would be very ideal to use for this so I need to find out what is available on a WCF app for ...

How to get the current open documents in Excel using C#?

All I need is to get the list of currently open documents in the currently open instance of Microsoft Excel. But I don't know Excel terminology to know if these documents are called workbooks, or sheets, or windows, etc. Any ideas ...

How to update an element with a List using LINQ and C#

I have a list of objects and I'd like to update a particular member variable within one of the objects. I understand LINQ is designed for query and not meant to update lists of immutable data. What would be the best way to accomplish this? I do not need to use LINQ for the solution if it is not most efficient. Would creating an Update ...

.net webservice for iphone app

Hi, I 'm trying to build an app which communicates with a web service. So far i have basic iphone app --hello world web service .net (version 1.1) I want the web service to return a pdf file. I can send the pdf in bytes. Is this the best approach. I 'm concerned that with the increase in pdf size the performance will degrade. Any s...

How to read the xml file and write its content into a plain text file?

How to read the below xml file and write its content into a plain text file? <!-- < config > < compare > < source >d:\demo\< /source > < destination >e:\demo\< / destination > < parameters > < parameter >FileName< /parameter> < parameter >Size< /parameter> < parameter>Date< /parameter> < /parameters > < /compare > < ...