Saturday, 21 July 2007
|
| dynamically addnig controls and viewstate Alex Smotritsky 04:09:06 |
| | I'm adding some controls to a webform in a click event handler. Since I do this on click I don't think I can do it in page load or init. I'm finding that these dynamically added controls are not saved in ViewState. Are there any work arounds for this? I'm thinking of putting them in session state.
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
Thursday, 19 July 2007
|
| XMLSerialization - continued Peter Osucha 19:30:50 |
| | What do you guys think about including a static method in a specific class to Serialize and Deserialize that object?
It seems like something reasonable to do. It would 'contain' the code in that class. However, perhaps there is something wrong with this train of thought...
Peter
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 2 answer | Add comment |
|
| XML Serialization Jeff 19:29:26 |
| | Has anyone gotten a stream to load successfully into an XmlDocument class?
I have something like this and it does not error out when loading the stream, but when I try to save the xmlDoc to disk just to see the output xml it fails telling me that the root element is missing. Wouldn't it fail when I initially try to load it? Any idea what I am doing wrong here? I can get it to work if I use a streamwrite and get it back as a string, but I wanted to avoid that since my only objective is to load it into an xml doc anyways, I figured I would rather avoid getting it from the stream as a string, since the XmlDocument.Load takes a Stream also.
public XmlDocument GetXmlAuthToSend() { Stream xmlStream = new MemoryStream(); Type type = AuthorizationRequestInstance.GetType(); XmlSerializer xmlSerializer = new XmlSerializer(type); xmlSerializer.Serialize(xmlStream,AuthorizationRequestInstance); xmlStream.Position = 0; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlStream); xmlStream.Close(); return xmlDoc; }
=================================== This list is hosted by DevelopMentor http://www.develop.com NEW! ASP.NET courses you may be interested in:
Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 25 answers | Add comment |
|
| RegExp for CSV Brady Kelly 18:58:35 |
| | I need to parse CSV file templates into field lists, and would like to use the System.Text.RegularExpressions class.
I've found this formidable looking regex at http://www.hotblue.com/article0000.aspx?a=0006, and wouldn't mind some assistance in dissecting it.
((?<field>[^\",\\r\\n]+) | \"(?<field>([^\"]|\"\")+)\") (, | (?<rowbreak>\\r\\n|\\n|$))
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 25 answers | Add comment |
Wednesday, 18 July 2007
|
| UserControl and datagridview Gabriel 17:08:13 |
| | Hello,
In a project I use an SQLServer Express database (with some record in a table). With VS2005 IDE, I created a datasources. When I drag and drop a table from the "data sources" window a datagridview is created. Normal.
When I do exactly the same thing on a UserControl, I see the Datagridview but no data and when I drop the user control on a form, I see the datagridview but no data. I can see the header columns but no data.
Do you have an idea what I can do ?
Regards,
|
| | Add comment |
Tuesday, 17 July 2007
|
| Saving Colors to a db Peter Osucha 23:56:49 |
| | Hi,
I am saving Color values to a database as integers after converting the color using the ToArgb() method. When I retrieve the color, I am resetting it using the FromArgb() method. However, this doesn't preserve the color name if the color has a name - as shown in this simple test proc.
private void Button3_Click ( object sender, EventArgs e ) { Color col1 = Color.DarkBlue; int col1int = col1.ToArgb ( ); Color col2 = Color.FromArgb ( col1int ); Console.WriteLine ( "{0}, {1}", col1, col2 ); }
If I desire to save and retrieve Colors to a database and to preserve the color name if it exists, I imagine I need to save a string of the name instead of the argb value?
Peter
|
| | 18 answers | Add comment |
Monday, 16 July 2007
|
| Scalable Layout Brady Kelly 13:06:42 |
| | I've just started using such things as TableLayoutPanel and SplitContainer in my WinForms apps. However, it seems that either I can't seem to get the right balance of Dock and Anchor properties, or that using these containers is taking me into HTML territory, where an apparaently simple layout actually requires several nested containers (nested tables in HTML layout) to correctly apportion areas for various label and content controls. Are there any good tutorials or guides for work like this?
|
| | Add comment |
|
| Updating UpdatePanel using update method programmatically Mark S. Potter 06:35:20 |
| | I wrote a simple 1 page AJAX site that has an update panel.
<asp:ScriptManager ID="ScriptManagerSingleServer" runat="server" />
<asp:updatepanel ID="UpdatepanelSingleServerInput" UpdateMode="Conditional" runat="server" />
The <ContentTemplate> contains some text boxes that I want to update programmatically from a long running server process that starts in a button postback event.
I am calling the Update method during the process multiple times but I am only getting the last update.
Is it possible to update the progress of a process multiple times during a postback using the Update method?
Thanks in advance.
Mark Potter
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 2 answer | Add comment |
Sunday, 15 July 2007
|
| System.Array's implementation of IList's indexer Fabian Schmied 13:31:26 |
| | A colleague of mine noticed something interesting today: Suppose you have a value type array and access it via its implementation of IList. If you then assign "null" to an element of that array (via IList), does this throw an exception or not?
For illustration:
using System; using System.Collections;
class Program { static void Main () { int[] array = new int[1] { 1 }; IList arrayAsList = array;
arrayAsList[0] = null; // ! } }
The answer is that it does not currently (on .NET 2.0) throw an exception; instead, the indexer treats the null reference as if it were zero. In the SSCLI, this is explained by the following comment in COMArrayInfo::SetValue (line 243): "Null is the universal zero..."
Does anybody know the rationale behind this automatic conversion? Intuitively, I'd have expected the indexer to throw an exception. (And the conversion only occurs for "null", not, for example, for "0.0" or "false").
Regards, Fabian
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 7 answers | Add comment |
Friday, 13 July 2007
|
| Loading 32/64-bit unmanaged DLLs Ron Inbar 21:18:52 |
| | Hi,
I want to compile my managed assemblies (both DLLs and EXEs) as AnyCPU. I have a small number of unmanaged DLLs, for some of which I have both a 32-bit version and a 64-bit version, and for others I only have a 32-bit version. Obviously, applications that load DLLs of the latter kind must be compiled as x86 to make them run as 32-bit processes on 64-bit systems. Regarding the former kind, I would still like to use AnyCPU rather than compile them twice. I found one way to do this, which is to put the 64-bit unmanaged DLLs under %windir%\system32 and their 32-bit equivalents under %windir%\syswow64, and let WoW64's redirection mechanism take care of loading the right DLL. However, I would like to restrict my installation scripts to my own directories and not put anything under %windir%. Is there a way to use registry redirection to achieve a similar behavior with directories other than %windir%\system32?
Thanks,
Ron Inbar Software Engineer Philips Medical Systems Haifa ISRAEL
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
|
| References for Setup Projects Peter Osucha 20:38:45 |
| | I am having a hard time trying to get at the details of Setup Projects for VS2005. Are there any good books or websites that have complete (OK, fairly complete) details on creating set projects (with details to setting up shortcuts, using other dialogs, installing additional items or applications, etc.)?
Sincerely,
peter
|
| | 1 answer | Add comment |
|
| VS 2005 Crashes on Expanding a DataSet Brady Kelly 17:41:38 |
| | I have a small, one form application that I wish to use for editing text data stored in two database tables. The data is imported into SQL Server from Access 2003.
I create a new database DataSource, and all goes well until I want to drag from the Data Sources view onto the form. The tree view only shows one of the tables, the 'master' table, and when I try and expand it to drag fields onto my form, VS crashes. It asks about sending an error report, but no readable error information is given, just a process dump.
How can I even begin diagnosing this?
|
| | Add comment |
Thursday, 12 July 2007
|
| communication between content pages Alex Smotritsky 20:39:21 |
| | I've found information on how to have master pages communicate to content pages and vice versa but not much on communication between content pages on a master page. Do content pages on a master page have to use the master page as a broker or can they directly reference each other when they want to communicate?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 2 answer | Add comment |
|
| Tooltips and MouseMove event Peter Osucha 17:08:23 |
| | I am drawing an array of circles, boxes, etc., on a graphics object associated with a panel control. The class I use to do this is called 'Cartridge'. So one of the items in the constructor of the Cartridge object is a panel control (though technically it could be any control to which I can get a reference to a graphics object) I am referring to as _canvas.
Anyway, I have realized that it would be very beneficial to provide tooltips when the mouse hovers over some of the shapes I have drawn. To try to implement this, I have created a ToolTip object in the Cartridge class and have attempted to set it in two places - first, an event handler connected to the _canvas.MouseMove() event; second, in an event handler connected to the _canvas.MouseHover() event. Neither produces the desired effect.
The MouseMove() event seems to fire at intervals of about 500 ms regardless of whether or not I am moving the Mouse over the _canvas. The MouseHover() event never (very, very seldom) seems to fire.
Any suggestions on what I can do to implement this tooltip functionality?
Peter
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 8 answers | Add comment |
|
| Dispose Andrew Dunn 15:07:24 |
| | Hi,
Can anyone see a better way of doing this. I have a class that holds an image as one of it's properties. This image is held in the windows temp directory. I want to delete it when the class is destroyed. Is Dispose the best place to do this? Is ~PatientPhoto() OK to call dispose?
public Bitmap Photo { get{ return _Photo;} set{ _Photo = value;} }
~PatientPhoto() { Dispose(); }
public void Dispose() { if(Photo != null) { if (Photo.Tag != null) { string FileLoc = Photo.Tag.ToString();
///Delete the photo file as it is stored in a temporary file in the windows temp directory if (File.Exists(FileLoc)) { Photo.Dispose(); Photo = null; try { File.Delete(FileLoc); } catch (IOException e) { System.Windows.Forms.MessageBox.Show(e.Message); } } } } }
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 3 answer | Add comment |
|
| MultipleActiveResultSets and ObjectDataSource Stephen G. Maczko 12:50:25 |
| | Has anyone seen an example of using SQL Server 2005 MultipleActiveResultSets connection in an ObjectDataSource for a web application.
I've begun my first system using ASP.NET 2.0, and it's a bit surprising how SLOW using new connections to a SQL Server 2005 on a different machine are.
Thanks~!
Steve Maczko
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
Wednesday, 11 July 2007
|
| loading an image in to Bitmap Andrew Dunn 23:54:02 |
| | Hi,
I'm trying to load an image in to the bitmap class. It is working ok, but I need to load it in to the bitmap class and not reference the file on the computer anymore. Eg:
Bitmap Photo = new (Bitmap)Bitmap.FromFile(FileName); File.Delete(FileName);
The second line will throw an error saying the file is in use. I have tried all difference combinations of new Bitmap() but all seem to keep referencing the file on the disk, is there any way to do this (just keep the image in memory)?
Thank you,
Andrew
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 2 answer | Add comment |
|
| content pages and code behind Alex Smotritsky 22:37:19 |
| | Is it correct to say that content pages do not support code behind?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 5 answers | Add comment |
|
| Modifying form controls Peter Osucha 20:00:55 |
| | Sometimes, I find that after I have created a form, wired up all the event handlers, and coded everything to work correctly, I decide to change a control that was put on the form first or to add another control (eg, a splitter). It seems to get the layout to work, I need to cut and paste controls which then 'unwires' all the event handlers.
I have been wondering for some time if there is a better way to do this so I don't have to go back and hook up all the event handlers. Is there?
Sincerely,
peter
|
| | 2 answer | Add comment |
|
| New client application Mark Gregory 19:46:29 |
| | I would appreciate knowing what is the fastest way to get a framework for a new ASP.NET 2 client.
I need the framework to include master pages, membership, skins / themes.
Is there a tool that will autogenerate a basic framework so that I can then start adding to it.
Regards, Mark
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 7 answers | Add comment |
Tuesday, 10 July 2007
|
| Cancel a BeginRecieve.... Mark Nicholls 10:43:03 |
| | On a Message queue
I know it's probably obvious....
but it isn't to me at the moment.
I've tried closing it and disposing it but it still seems to get triggered.
=================================== This list is hosted by DevelopMentor® http://www.develop.com Some .NET courses you may be interested in:
Guerrilla ASP.NET, May 17, 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls
Guerrilla.NET, June 28, 2004, in Los Angeles http://www.develop.com/courses/gdotnetls
Guerrilla.NET, July 5, 2004, in London. UK http://www.develop.com/courses/gdotnetls
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 4 answer | Add comment |
Sunday, 8 July 2007
|
| The reasons for System.Nullable's existence (not System.Nullable<T>) Jon Skeet 22:30:32 |
| | Hi everyone,
I'm trying to work out why the Nullable class exists to support the Nullable<T> struct. The simple answer which comes to mind is that static helper methods on non-generic types are a lot simpler than those on generic types, because even if the method doesn't use the type parameter, you still need to provide that type parameter for static methods in generic types.
However, let's have a look at what the methods are:
1) GetUnderlyingType (Type) - couldn't this be a method in Type, just like GetElementType is? (It would probably have to be renamed, admittedly.)
2) Compare<T> - given that it's a generic method (so you have to provide the type parameter anyway) why not just have it as a static method on Nullable<T>?
3) Equals<T> - ditto.
Now, type inferencing makes it *slightly* easier to call static methods on the Nullable class, but I don't think that makes it worth having the separate type. In fact, Equals is already an instance method on Nullable<T> and Compare could be too. That would make those methods unsuitable for delegates, but other than that they'd be fine.
I've looked on the web and not found anything about this - it seems to be just taken for granted that having a separate class would be a good idea.
Anyone got any thoughts?
Jon
=================================== This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 9 answers | Add comment |
|
| Making threadsafe calls : C# 2005 Peter Osucha 21:13:48 |
| | Hi guys,
I occasionally forget (well more often than not I cheat and ignore the errors) to make threadsafe calls to form controls. A good example I am facing now - I have an object ('Instrument') that is handling messages from a connected actual hardware instrument by way of a TCP Socket connection. This Instrument object raises many events so that a subscribing form containing an object instance can provide feedback to the user.
So I have reviewed the 'How to make thread safe calls to Windows Form Controls' topic in MSDN and I am puzzled by the example (or I just don't understand it well). The topic offers a code sample (shown below)...
// This event handler creates a thread that calls a
// Windows Forms control in a thread-safe way.
private void setTextSafeBtn_Click(
object sender,
EventArgs e)
{
this.demoThread =
new Thread(new ThreadStart(this.ThreadProcSafe));
this.demoThread.Start();
}
// This method is executed on the worker thread and makes
// a thread-safe call on the TextBox control.
private void ThreadProcSafe()
{
this.SetText("This text was set safely.");
}
It seems that to implement this type of thread-safe calling will require a whole lot of code (it seems that I will need such a 'setup' for modifying each and every form control I want to modify.
Maybe a more concrete example of what I'm talking about would be useful. My Instrument object raises among other events a 'DataReceived() event' which the form has a handler for. When this event is handled by the form, it updates several controls on the form. So I can see how I would create a 'demoThread' in the event handler that calls a separate method (similar to 'ThreadProcSafe' in the example above) but it seems that I'd have to call several different 'ThreadProcSafe' methods to handle all the controls updating I require. I guess I could have the newly created friend call a method called UpdateFormControls (that updates every control on the form whether its needed or not) but that seems like a not-too-good way to do the updating.
Surely I'm missing something. Any comments?
Sincerely,
peter
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 10 answers | Add comment |
Friday, 6 July 2007
|
| programmatically adding controls and ViewState Alex Smotritsky 23:53:32 |
| | This Microsoft page:
http://msdn2.microsoft.com/en-us/library/hbdfdyh7(VS.80).aspx
says:
If you insert dynamic controls between existing controls, the dynamic control's view state information is inserted into the corresponding location of the view state structure. When the page is posted and the view state is loaded, the dynamic control does not yet exist; therefore, the extra information in view state does not correspond to the right control. The result is usually an error indicating an invalid cast.
A control I'm dynamically inserting is disappearing on postback. I think that's because of the above mentioned issue. Is there a solution to this?
=================================== This list is hosted by DevelopMentor http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|
| | 1 answer | Add comment |
|
| Failed to install Framework 3.0 redistributable for Windows XP x86 Lizet Pena de Sola 23:53:32 |
| | Hi all, Could anyone point me to the proper documentation for failed Framework 3.0 installations. I'm running Windows XP SP2 and got a 1603 error while installing WCF. The last few lines of the error log VSSWMSIFailInfo.txt are:
MSI (s) (D4 8) [16:03:43:672]: Executing op: CustomActionSchedule(Action=DD_CA_InstallXwsRegExe_RB_X86.3643236F_FC70_11D3_A536_0090278A1BB8,ActionType=1345,Source=BinaryData,Target=QuietExec,CustomActionData=C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe /u /x /y /v;dummy;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\) MSI (s) (D4 8) [16:03:43:672]: Executing op: ActionStart(Name=DD_CA_InstallXwsRegExe_X86.3643236F_FC70_11D3_A536_0090278A1BB8,,) MSI (s) (D4 8) [16:03:43:672]: Executing op: CustomActionSchedule(Action=DD_CA_InstallXwsRegExe_X86.3643236F_FC70_11D3_A536_0090278A1BB8,ActionType=3073,Source=BinaryData,Target=QuietExec,CustomActionData=C:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe /r /x /y /v;dummy;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\) MSI (s) (D4:10) [16:03:43:692]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSI6CB.tmp, Entrypoint: QuietExec MSI (s) (D4:38) [16:03:43:692]: Generating random cookie. MSI (s) (D4:38) [16:03:43:712]: Created Custom Action Server with PID 2336 (0x920). MSI (s) (D4:B8) [16:03:43:802]: Running as a service. MSI (s) (D4:B8) [16:03:43:812]: Hello, I'm your 32bit Elevated custom action server. MSI (s) (D4 8) [16:03:45:134]: User policy value 'DisableRollback' is 0 MSI (s) (D4 8) [16:03:45:144]: Machine policy value 'DisableRollback' is 0 Action ended 16:03:45: InstallFinalize. Return value 3. MSI (s) (D4 8) [16:03:45:144]: Executing op: Header(Signature=1397708873,Version=301,Timestamp=921075827,LangId=0,Platform=0,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1) MSI (s) (D4 8) [16:03:45:144]: Executing op: DialogInfo(Type=0,Argument=0) MSI (s) (D4 8) [16:03:45:144]: Executing op: DialogInfo(Type=1,Argument=Windows Communication Foundation) MSI (s) (D4 8) [16:03:45:144]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1])
Thanks, Lizet
|
| | Add comment |
|