Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Articles
Search: 

Bonnie Berent's Tips
Bonnie DeWitt, March 1, 2006
Great tips for .NET developers
Summary
Great tips for .NET developers
Description

Connection Strings from Config files
Visual Studio 2005 (2.0) differs slightly from 2003 (1.1) in the way you can get ConnectionStrings from the Config file, although the same code that works in 2003 will still work in 2005.
The config file in 1.1 might look something like this:
<?xml version="1.0" standalone="yes"?>
<configuration>
  <appSettings>
    <add key="ConnectionString" 
     value="server=MyServer;database=MyDataBase;uid=UserName;pwd=MyPassword" />
  </appSettings>
</configuration>

In 2.0, connectionStrings have their own section under the appSettings:
<?xml version="1.0" standalone="yes"?>
<configuration>
   <appSettings/>
      <connectionStrings>
          <add name="WebShopper" 
           connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=WebShopper;
           Integrated Security=True"
           providerName="System.Data.SqlClient"/>
          <add name="LocalSqlServer" 
           connectionString="Data Source=.\SQLEXPRESS;initial catalog=WebSite;
           integrated security=SSPI;persist security info=False;workstation id=WTI01;
           packet size=4096" providerName="System.Data.SqlClient"/>
      </connectionStrings>
   </appSettings/>
</configuration>

In 1.1, you get the ConnectionString using the ConfigurationSettings class:
   string cConnection = ConfigurationSettings.AppSettings["ConnectionString"];

In 2.0, there is a new class, ConfigurationManager, to get the ConnectionStrings:
   string ConnectionString = 
    ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;

Note that the 1.1 ConfigurationSettings class still works just fine in 2.0.

from a solution provided by Michael McLain and Bonnie Berent in Message #1071823 and Message #989055

Descriptions in the Property Sheet
You've created a property in your visual control, and when you drop the control on a Form, you can see the property in the Property Sheet ... now, a nice description describing what that property is for would be nice ... how do you do this? Simple, you need to use the Description attribute:
[Description("I want this string to appear in the property sheet")]
 public string FieldName
 {
   get
   {
     return m_FieldName;
   }
   set
   {
     m_FieldName = value;
   }
 }

from a solution provided by Bonnie Berent in Message #1047861

Convert HTML Forms to Web Forms
It's pretty easy to convert a simple data entry HTML form to a Web Form. Open the HTML in the VS IDE, save it as an ASPX file and add runat="server" in the form tag and for all the controls.

from a solution provided by Çetin Basöz (and Daniel Aldridge) in Message #1069900 (and #1069960)

Is It Modal?
Here's how to tell if a Form has been opened with .Show() or .ShowDialog().
If Me.Modal Then
   ' Form opened with .ShowDialog()
Else
   ' Form opened with .Show()
Endif

from a solution provided by Chris McCandless in Message #1063671

Bonnie DeWitt, Geneva Systems Group
Bonnie is currently one of the principals of Geneva Systems Group. Call her the Senior Software Engineer, or even call her the VP of Engineering. She has no official title at the moment. Bonnie has been writing software in various languages for about 30 years. Bonnie's current focus on C# .NET applications began in early 2002. She has been a Microsoft C# MVP since Oct 2003 and an active member of the .NET online community.
More articles from this author
Bonnie DeWitt, September 1, 2005
Great tips for .NET developers
Bonnie DeWitt, October 1, 2005
Great tips for .NET developers
Bonnie DeWitt, November 1, 2005
Great tips for .NET developers
Bonnie DeWitt, December 1, 2005
Great tips for .NET developers
Bonnie DeWitt, April 1, 2009
Great tips from the .NET developer community compiled by Bonnie Berent.
Bonnie DeWitt, February 1, 2006
Great tips for .NET developers
Bonnie DeWitt, April 1, 2006
Great tips for .NET developers
Bonnie DeWitt, May 1, 2006
Great tips for .NET developers
Bonnie DeWitt, June 1, 2006
Great tips for .NET developers
Bonnie DeWitt, July 1, 2006
Great tips for .NET developers
Bonnie DeWitt, August 1, 2006
Great tips for .NET developers
Bonnie DeWitt, September 1, 2006
Great tips for .NET developers
Bonnie DeWitt, October 1, 2006
Great tips for .NET developers
Bonnie DeWitt, November 1, 2006
Great tips for .NET developers
Bonnie DeWitt, December 1, 2006
Great tips for .NET developers
Bonnie DeWitt, January 1, 2007
Great tips for .NET developers
Bonnie DeWitt, February 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, March 1, 2006
Great tips for .NET developers.
Bonnie DeWitt, April 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, March 1, 2007
Good tips for .NET developers.
Bonnie DeWitt, May 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, June 1, 2007
Great tips and tricks for .NET developers.
Bonnie DeWitt, July 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, August 1, 2007
Great tips for .NET developers
Bonnie DeWitt, September 1, 2007
Great tips for .NET developers.
Bonnie DeWitt, February 1, 2008
Great tips from the Universal Thread .NET community.
Bonnie DeWitt, March 1, 2008
Great tips for .NET developers selected from the community by Bonnie Berent.
Bonnie DeWitt, April 1, 2008
Great tips from the .NET developer community compiled by Bonnie Berent.
Bonnie DeWitt, January 1, 2006
Great tips for .NET developers