Pages

Showing posts with label Visual Web Developer 2008. Show all posts
Showing posts with label Visual Web Developer 2008. Show all posts

Monday, February 23, 2009

Connection Strings, Web.Config, and the Development Environment

Ok, admittedly it's not as enticing as Sex, Lies, and Video Tape, but this is an awesome way of helping you with ASP.NET website development.

The Problem

You create a site on your local machine(s) and get it working perfectly. Now it comes time to publish your changes to the live website, and you run into a giant problem whenever there are any changes to your web.config file. All your connectionstrings (Data Source=localhost\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True) and configurations get promoted to the live site, where they fail until they are hand-edited to reflect the web site's configuration. Alternately, you can forbid the publishing of web.config, forcing all changes to this one file to be done by hand.

Following is a procedure showing how to remove the appSettings and connectionStrings sections into a separate file, enabling the publishing of web.config whenever without hand-editing.

  1. with your project open, add a new item (control-shift-A).
  2. choose Web Configuration File and name it appsettings.config Ignore the text that Visual Web Developer automatically puts in there.
  3. create another one named connectionstrings.config.
  4. wipe the text from these 2 new files.
  5. copy the appSettings section from your web.config appSettings section into the appsettings.config file. It should look like this:
    <appSettings>
    <add key="connectionstring" value="Data Source=localhost\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True"/>
    </appSettings>
  6. now do the same for connectionstrings:
    <connectionStrings >
    <add name="ConnectionString" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True"   providerName="System.Data.SqlClient"/>
    </connectionStrings>
  7. Now replace these sections only in your web.config file as follows:
    
    <appSettings configSource="appsettings.config"> </appSettings>
    <connectionStrings configSource="connectionstrings.config"> </connectionStrings>
  8. Note: if anyone knows how to tell the Copy Web Site dialog to NEVER publish these files, I am all ears.

Now you can hand-edit the web server's copy of appSettings.config and connectionstrings.config to give them the correct environment for the webserver. If you can't edit these remotely, then you can edit them on the development server, publish them and then change them back for your development environment.

Friday, June 27, 2008

Choosing Another Database for Membership and Roles


By default, Visual Studio Express likes to store all its membership and roles data in a local user instance provider called AspNetSqlProvider that uses a database called ASPNETDB.MDF in your APP_DATA directory in your project. This type of database is called a user instance.
I think it would be beneficial to expose some terms here.
  • provider: this is an asp.net object that supplies information to the website software. There can be numerous providers in an application and a provider doesn't necessarily connect to a database. It could just as easily connect to an XML file, a text file, a random number generator or a golden retriever...
  • membership: is the information about members, i.e. login, password, email address, etc.
  • roles: This data can be kept separate from the membership data and describes what roles are assigned to each user (admin, guest, moderator, whatever) It also contains information about what roles have access to which features in your site.
  • user instance: This is a database stored in your APP_DATA directory. There are severe performance issues with this type of database, and many ASP hosts do not support user instances.
  • MSSQL Express: This is the free version of Microsoft SQL Server Database (MSSQL). even though a user instance database is this type of a database, in this article MSSQL Express database refers to a database created with SQL Server Management Studio Express tools. These databases are not a part of your website, but can be accessed by one or more websites. The data does not exist in your website folders and must be published separately.
  • MSSQL: Microsoft SQL Server is the full paid version of SQL server (the one you'll probably use on your live website if you are a corporate developer, or you're using a professional ASP.net web hosting service.
Ok. So you (like me) want to stop Visual Web Developer from using the user instance, and tell it to use a MSSQL Express database, and you do not want to write your own provider objects. Here is the step by step plan to do this.

Create a New Database

This assumes that you are not using an already existing database... if you already have a MSSQL Express database you can skip this step. Just open SQL Server Management Studio Express (download it if you don't already have it) and create an empty database.

Add the Membership and Roles Tables

There is a special program you can use for this, but you must learn the secret handshake. This program is part of the .NET framework and resides in your .net folders. The program name is Aspnet_regsql.exe and I suggest you find it by browsing to C:\WINDOWS\Microsoft.NET\Framework and doing a search for Aspnet_regsql.exe. On my system I find one copy of it in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder (strangely not in the v3.0 or v3.5 folders).
Launch the program.
Click Next.
Select Configure SQL... and click Next.

The Server is the Windows name of your computer, but WAIT, don't pop open that Database list or you'll get the dreaded...
Connection failed
Failed to query a list of database names from the SQL server. An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
...error.
This is not Microsoft's finest work, and this is where you must know the secret handshake I mentioned earlier. You must alter your Server Name to make this tool recognize that we're using SQLExpress. Add \SQLEXPRESS to the end of your computer name. Mine reads THEDOCTOR\SQLEXPRESS.  It also worked to use .\SQLEXPRESS.  Note also that if you named your SQL server something else when you installed it, you need to use that name.  The pop-down list will be enabled to open and there will be a list of all the databases on your machine.
Databases can be shared across machines too - in case your database isn't on the same machine that you develop on.

Select your new database and click Next.
Review and if all is well, click Next again.
Click Finish.

The database is ready for you to create membership and roles info. Now all we have to do is...

Tell web.config about the new database.

There are 3 steps for this.
  1. create a connection string.
  2. hook up the Membership provider.
  3. hook up the Roles Manager.
Here are the sections of my web.config that worked.

1. The Connection String

<connectionStrings>
<add name="MYDATABASE" connectionString="Data Source=THEDOCTOR\SQLEXPRESS;Initial Catalog=AFIDatabase;Integrated Security=True" providerName=".NET Framework Data Provider for SQL Server" />
</connectionStrings>
The bold text should be changed to reflect your database and server names. The name property (in green) will be needed to identify the connectionstring to the providers.

2. The Membership Provider

<membership defaultProvider="MyProvider" userIsOnlineTimeWindow="30">
<providers>
<clear/>
<add connectionStringName="MYDATABASE" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" name="MyProvider" type="System.Web.Security.SqlMembershipProvider" />
</providers>
</membership>
The clear removes any references to the default databases from machine.config.
Note that the Membership object contains the definition of the provider which contains a reference to the connection string. The applicationName property is used to identify the application - you can share this name across many websites to allow a single signon for many sites.
So the membership object uses the MyProvider provider which uses the MyDatabase database.
( Membership object -> MyProvider -> MyDatabase )

3. the Roles Manager

<roleManager enabled="true" defaultProvider="MyProvider">
<providers>
<clear/>
<add connectionStringName="MYDATABASE" applicationName="/" name="MyProvider" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
Note that even though I named the provider MyProvider again, it is in fact a different object. However, this allows me to use the Single Provider setting in the website settings page in Visual Web Developer.
Now if you open the ASP.NET Configuration page from Visual Web Developer (Website - ASP.NET Configuration) and click the "Providers" tab, then the "Single Provider" option, you should see the new provider you just created, and it should already be connected.
If the configuration page crashes for any reason, there are a few things to try.
  • ensure that the names of your providers match the "defaultProvider" property exactly.
  • ensure that you have used the same applicationName everywhere.
  • ensure that the connectionStringName in your providers exactly match the name in your connectionStrings section.

For Further Reading

Many thanks to Rob Mills and Guru Bhai for their help figuring this out.

Tuesday, June 17, 2008

Using A Different Database as a Membership Provider in ASP.NET

There should be no need for me to ask this but after 2 days of ditzing around trying to make this work I am at the end of my patience. Linux is looking better all the time.

Ok, I created a website with security and it works great on my desktop, the performance sucks (utterly) on the test webserver, and I cannot use it at all on the production server. That's because we must use real MSSQL in production rather than a user instance, the production environment does not support user instances.

All I need is to tell my membership, role, and security objects, "Look over here, not over there". One would think that altering a connectionstring and replicating the membership tables would be all thats needed.

But NO.

Plus, I can't seem to find a comprehensive tutorial on this anywhere, so I'm mixing info from blogs and msdn and whatnot trying to make this work. Most of the tutorials out there are for MSSQL2000 (I'm using 2005) and a mix of ASP.NET 2.0 and 3.5 (Im using 3.5 - I think)

Here is what I want.

On my workstation, I want the authentication to look in my local MSSQL Express database for ALL security info.

In Production, I want the web server to look in the FULL MSSQL database for this info.

I do NOT NOT NOT want to re-engineer membership and roles objects.

Here's what I have found so far.

http://msdn.microsoft.com/en-us/library/sx3h274z.aspx - generic - no specifics

http://msdn.microsoft.com/en-us/library/6e9y4s5t.aspx - this adds my new database to the MEMBERSHIP selection but not the Single Provider or Role Provider

http://msdn.microsoft.com/en-us/library/2fx93s7w.aspx - This helps you create the table structure in your database, but leaves out 1 critical piece of info... the fact that I had to type "/sqlexpress" after the server name or it crashes when you try to drop down the list.

http://forums.asp.net/p/980214/2369556.aspx - This is where I found out you have to type "/sqlexpress"

http://msdn.microsoft.com/en-us/library/ms998317.aspx - not sure if "Forms Authentication" is what I'm doing or not...

Wednesday, April 30, 2008

Using Subversion with Visual Web Developer

*Note: this method doesn't just work for Visual Web Developer, it should work for any software where source files are stored on your local drives. This includes C#, C++, Java, VB, Delphi, C++ Builder, Flash, Poser, etc.

This tutorial will get you started using Tortoise SVN to easily back up and version your websites. If you don't know why this is a great idea, then you've never screwed up your projects so bad that you wasted 3 days trying to get it back to where you started.

Step 1

Find a spot to back up your stuff. I use an external USB drive. There are also ways to do this over the intranet and Internet. You can store your archive (subversion calls this a repository) on your main hard drive, or another computer in your network as well.

Step 2

Download and install Tortoise SVN for windows. Once installed, right-click nearly any file on your system and note the new options that are available (Don't select them yet, just *note* them).

Step 3

Create a folder on your archive drive to put a project in. In my case, on the external drive it's named like this: I:\subversion\Website1.

Then navigate to the parent folder and right-click the project archive folder (in my case this was I:\subversion) and right-click the new archive folder (Website1). Choose TortoiseSVN - Create Repository Here. Select Native Filesystem (FSFS). This takes a few 10ths of a second, and creates files and folders in the archive folder.

Step 4

Now browse back to your websites folder (the place where you have the files to be archived) and right-click the project you want to check in. Select TortoiseSVN - Import. It is important to note that to Tortoise, import means "import to the archive" and export means "Pull it out of the archive". In the import dialog select the archive folder you just created (such as file:///I:/Subversion/Website1. Click OK. The contents of your project will be imported into the repository. Click OK.

Now whenever you change a file in your project, you can upload the changes to the repository, and if you mess it up, you can roll it back in an instant! I'll do more tutorials about using Tortoise SVN later.


Apologies for the delay...

Yes, you must use tortoise to check out the project again. I suggest checking it out to a new folder. There are some Windows sharing settings that will cause errors here if you are saving to a shared drive. I am still looking into this.

Thursday, March 20, 2008

Missing Event Handlers

First, has anyone other than me noticed that it takes like 2+ minutes for Visual Web Developer to fully open and come alive? What the hell is it doing? We'll save that for another time.

So you create an Ajax Web Form. You want to put an even handler on Init of the form. How? There is no event icon in the object inspector for the document.

So you click on the Script manager and presto! you get the little lightning bolt icon.

Let's try it with a master page. We create a master and a content page and guess what? There is NO WAY to add an onInit handler to the content page. There's no script manager. If you open the .cs code file and/or double-click the page in the designer, you get a page_load function.

You can try to add one by hand, but where would you put that?....

Ok lets move on.

Slap a button on the screen, and then select the button. Wohoo! the little lightning bolt is there!

Now create a table and put in a row and a cell and put the button in there. Oops, you can no longer click the button and create event handlers, you keep getting the table. In fact the only way I have found to add a handler is to drag the button out of all the panels, tables, etc., and edit it's event handlers, then drag it back into it's table cell and hope it all works.

This is goofy.

The solution is to create all components you need to access the events of outside all tables tables or panels, create the event handlers and then drag (or cut/paste) the objects back into the table or panel.

Tuesday, March 11, 2008

IE7 Displays Blank Page: Firefox OK.

When I try to browse to my website, which contins an ASP page, I get a blank page for IE7, yet all is well for Firefox.

View Source in Firefox gives the normal page, while IE just shows this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; 
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

The page had some Flash embedded, but I get this result even after removing it. Im heading for "Clearly, IE is BROKEN". What MORON would have a browser substitute a blank page without any kind of error or warning message?


I found the solution after pulling an all-nighter on it.

This had to do with a database error: here's what happened. For some reason the database error was NOT getting reported to the browser, it just got a blank page.

I store the data from every hit in a table for diagnosing problems. That data element was a varchar(250), which up until now was more than adequate. The string from a firefox hit comes in at 163 and looks like this:

03/10/2008 16:24:14 Mozilla Netscape 5.0 (Windows; en-US) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 en-US Win32

However IE7 sends this for the exact same page:

03/10/2008 16:24:14 Mozilla Microsoft Internet Explorer 4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) undefined Win32

That's a whopping 380 characters, which caused a string length error on my SQL insert command.

I still don't understand why in hell it returned a completely blank page to IE without any errors listed but whatever, I'm re-doing the whole site in ASP.NET anyways.

The ANSWER: I had to stretch the database column where I'm storing the hit data strings to 1000 characters. That ought to hold me until IE8 SP2 at least.

Sunday, February 17, 2008

Permissions...

This article is about setting up private, member-only areas of your website that are either for admins or clients to access. The .net framework gives several easy ways to set this up with a minimal amount of coding.

Assuming you already have a website, and wat to add a restricted zone, do this:

First, enable permissions for your website

WebSite->ASP.NET Configuration
Browse to the security tab.

There are essentially 3 things to configure: Users, Roles, and Access. By default this data is stored in a MSSQL database in your website's folder structure.

I like to enable roles first, creating roles like client, admin, mod, or whatever. This process is easy enough. For this tutorial, create a user, and give it the admin role. Now before we can add access, we'll close the config screen and return to our project.

Create a folder



Add any html or aspx web page to the new folder. Add a link to the new page to your main website.

If you run the website now, you get free access to the new page (we haven't limited access yet).

Return to the ASP.NET Configuration and on the security tab, click Manage Access Rules.

Click on the new admin directory and then add allow permission for admin role. Then add deny permission for all.

The way this works is that this list is accessed from top to bottom, looking for a permission to apply. The first match that is found is applied. Therefore if we gave the deny - all permission first, then nobody would have any access to the folder.

The Login Page

By default, the login page is named login.aspx. This page will load any time that the client doesn't have sufficient privileges to access the page asked for. It must be in the unprotected part of your website.

So create a new page named login.aspx. Add in a login and password recovery gizmo from the login tab of the toolbox. Click on the gizmos and use the Auto Format function from the pop-out box to select the perfect style.

That's it.

Now anytime the user tries to access a page that he's not logged in for, he first gets the login screen. If he is already logged in, he gets the screen he asked for without interruption.

It's cool. I know.

Monday, January 21, 2008

Why is EVERYTHING so Damned Hard?

Windows 2003 SBS ASP.NET 2008 Express SQL Server 2005 .net framework 3.5 (not beta)

So, I wanted to add a login page to my website and offer more content to logged-in users. I saw the login components and followed the tutorial to the letter. It works on my desktop perfectly. I can create logins and even the forgot my password crap works. I publish it to my website, and try to log in.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

Oh, shit! So I search the help (when am I going to learn?) and it tells me that all I have to do is open an Application that DOES NOT EXIST on my server, and grant THE INTERNET access to my DATABASE. I don't think so.

Please, if you know what is wrong, go to http://209software.com/Login.aspx and use the username "a" and the password "a". It's not a valid login, but it crashes every time trying to verify.

My web server, email server, and database server are all the same machine.

Here's what I want to know, and MSDN has squat on it.

  1. if I grant database access to the database, can people BROWSE my database over the web?
  2. What am I doing wrong? and how do I make it right?
  3. WHERE on the internet can you go if the Microsoft help is crap?

Ok, I got it. I downloaded something, but it wasn't SQL server 2005 express. Now, a mere 8 hours of downloading and installing later, it seems to work.

Tuesday, November 13, 2007

Day 2

housekeeping

Here are the books and websites I use most when the answers are not coming to me.

C# for Programmers (2nd Edition) (Deitel Developer Series)

Pop open Microsoft Visual C# 2008 Express Edition - I suggest you pin it to your start menu.

Notice the area in the center, called the Start Page.

Now look closer at the "Getting Started" section.

There are actually some good resources there for you to use.

ready, set, go.

Today we create our first application.

Sadly it'll be a console app.

Click File - New Project - Console Application. You'll get something that looks like this:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
  class Program
  {
      static void Main(string[] args)
      {
      }
  }
}

The using's are all the .net namespaces or libraries that are included in the project by default.

The ConsoleApplication1 namespace is your own private realm where your code exists. All .net code exists in a namespace.

Variables

As I mentioned, all things in C# are class objects. The difference between a class object and a variable are that class objects can contain methods and they can be extended. An int in Delphi can't have any of its own functions, but in C#, even the simplest data object can and does.

Do this: Add this to the code above.

      static void Main(string[] args)
      {
          int x;
          int y = 2;
          x = 7;
          int z = x + y;          
      }
  }

int x; creates an integer class object but does not assign it a default value. Any attempt to read or manipulate it at this point would cause an exception.

The int y = 2; line shows a shorthand way of creating and initializing the value at the same time.

The x = 7; shows how to add or change data in an existing data object.

The int z = x + y; line shows a variable z being created containing the results of a calculation. Note that subsequent changes to x and y will not cause z to recalculate, it just works the math at the time and stores it in z.

Now do this. Type z. and a popup context helper appears. This shows the methods that can be accessed from an int.

if you mouse-hover over the items you get an explanation like this.

Ok, time to move on to...

EMail Demo

Now clear out all the varibables and type in the word MailMessage as shown.

Note the little rectangle under the "e". Hover your mouse over that and you'll see this:

What the IDE is offering to do is add the namespace System.Net.Mail to your using section or, alternately, add it to the declaration itself. You don't have to add a namespace to your project to access it, you can explicitly pick objects from any namespace by using their fully qualified name. Adding them to the using clause just simplifies the typing.

In this case, choose the first one, add System.Net.Mail to the using section.

Now you'll see the using System.Net.Mail; has been added to the top section of the program and all the objects and methods in that namespace are now native to your program.

The MailMessage class is an object that can be used to send or receive email messages. You can create an empty one and load it later like this...


MailMessage myMailMessage = new MailMessage();
myMailMessage.To = new MailAddress("bryanv@eloan.com", "Bryan Valencia");
myMailMessage.From = new MailAddress("gumby@eloan.com", "Gumby and Pokey");
myMailMessage.Subject = "I am feeling down again.";
myMailMessage.Body = "I am all congested with disclosures.";

Or you can create it and initialize it with variables. Note that we had to create 2 MailAddress objects to set the To and From addresses in myMailMessage.

The following example shows how to create a MailMessage object with all its values pre-initialized.


      static void Main(string[] args)
      {
          MailMessage myMailMessage = new MailMessage(
              "gumby@eloan.com",
              "bryanv@eloan.com",
              "I am feeling down again.",
              "I am all congested with disclosures."
          );
      }


Ok, now let's send this bad-boy. In order to do that (and please feel free to substitute your own address for the To address), you need an object called the SMTPClient. It's in the same namespace as the MailMessage.


      static void Main(string[] args)
      {
          MailMessage myMailMessage = new MailMessage(
              "gumby@eloan.com",
              "bryanv@eloan.com",
              "I am feeling down again.",
              "I am all congested with disclosures."
          );

          SmtpClient mySMPTClient = new SmtpClient("eloan.com");
          mySMPTClient.Send(myMailMessage);

          Console.WriteLine("Message Sent");
      }

Now, hit Control-F5, or from the menu, Debug - Start without debugging. You should get this:

Then in about 10 seconds, whoever you decided to bless with your email should see it in their inbox.

Let me diagram what we just did. When we created the MailMessage object, here's what was happening:

what we typedwhat happened
MailMessageWe told C# that we are about to create an object of the class MailMessage in the System.Net.Mail namespace.
myMailMessagewe told C# that we are going to call it myMailMessage.
= new MailMessage(...)We told C# to go ahead and create it now - that means to allocate memory and initialize it with either default values or the ones we are passing in. The object is now created and resides somewhere in memory, and can be accessed by the name myMailMessage.

Constructors

Every class object has a predefined method called a constructor. It tells C# how to create instances of itself. Constructors can be simple, like the constructor for an int, or more complicated like the one for MailMessage. They can even be overloaded.

Try this:

Note how the context helper pops up a helper for the constructor. There are 4 overloaded constructors for the MailMessage class. Use the down arrow key to see the formats you can choose from. All methods in all objects will pop these helpers while you are editing.

A few little items

Single quotes and double quotes are not interchangeable. Strings use the double quote marks "like this". Chars use the single quote (or tickmark or apostrophe), like this: 'A'.

A class is the organization of an object, an object is an instance of that class. Or, think of classes as cookie cutters (or blueprints) and objects as cookies (or Lear Jets).

Overloading means that there can be many methods with the same name. More on this later.

Monday, November 12, 2007

Getting Started with Visual Studio Part 1

This is intended to be a quick start tutorial so make sure to read them all in order. Use the GettingStarted Label on the web page to find all the articles in this series. This is the result of what happened to us last week. We had been promised a class in C#.NET to accommodate an upgrade project, but instead, most of us got laid off. Since I had been to the pre-training training, I attempt here to share the wealth.

This tutorial will use the Visual Studio 2008 Express (free) editions only, and will cover ASP.NET and C#.NET development ONLY. There will be no VB or J# here. Also, I am not a Microsoft hack, so when something sucks, I'll say so. Ok, on with it.

First topic: Getting the software.

Today the software may be found here.

If this page is not live anymore, then try googling for VS Express 2008 Download. Be sure to download C# and Visual Web Developer.

Accept all the defaults and reboot between and after the installs. Now you will see the IDE's under Start - All Programs.

Let's get started.

Click on the Visual Studio 2008 link to bring up the IDE. It takes the news channel several seconds to load so be patient. Let's talk about some conceptual topics before we start coding.

C# is like C++

Yes, it's kind of like C++ and kind of like Java. Everything is a class object. Even strings and integers are classes. Even though C# makes it easy to instantiate them, they are very much the same.

Managed memory

Because of the way the .NET framework manages memory, you need not worry about memory and resource leaks. When the memory manager notices that nobody is holding a pointer to some object, it places it on a list of items that can be wiped. This means that you as a developer have no control over when objects are destroyed, and no guarantee that they'll be destroyed in any particular order, even if the item is a parent of an object that is not being destroyed. I know, it's not the coder's way. Get over it.

CLR and Languages

The Microsoft Common Language Runtime makes it so you can create objects in one language and use them freely in another. For instance a Zip code lookup object in C# can be used in J#, VB.NET, or other C# projects. The CLR is your friend. Gone are the days of having to rewrite all your Delphi Projects into VB. You're going to like this, I promise.

Tomorrow, our first project. Don't forget to bookmark this. Your assignment for tonight is to download and install C#, ASP.NET, and optionally the GIMP.

Monday, October 8, 2007

Using GIMP to slice an image (in 45 seconds).

open gimp create a background (file-new-200x200-ok) Create a sliceable backdrop This part is subject to your creativity... Ok now... In this example we will slice the graphic into 3 horizontal stripes so we can use them for a menu. The same principles can be applied to slice the graphic into vertical stripes or even into a tic-tac-toe pattern for making table-based web pages. Image-guides-new guide You should see two dividing lines in the image... Now to split it... Image - transform - guillotine 3 files are created, you can save them under whatever names you like. Now you can use them to make borders to spice up your menus and web pages!

Monday, September 17, 2007

Microsoft, your Help is Crap!

Ok, I want to use asp.net to build a simple email form that send me an email whenever someone wants to contact me from my website. I figured that after all the easy-login stuff on the toolbar, there would be some kind of ready-made gizmo.

There isn't

Furthermore, when you use the trusty F1, and type asp email form tutorial or simple form tutorial, you get nothing but totally irrelevant crap from the results screen.

So I googled it and ALL the results fall into one of 2 categories.

  1. downloadable components
  2. vb.net

What the hell?

So here I am writing like 300 lines of code, and I know it HAS TO BE easier than this... why is it any harder than this?

smtp.send(
 mailmessage(
  request.querystrings("to").tostring(),
  request.querystrings("from").tostring(),
  request.querystrings("subject").tostring(),
  request.querystrings("body").tostring()
 )
)

Why, indeed?

Thursday, August 30, 2007

ASP.NET 2008 Beta: '"SqlDataSource1";' could not be found.

When you get this error in Visual Web Developer 2008 Beta:

The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource. A control with ID '"SqlDataSource1";' could not be found.

do this:

Find the Code that looks like this:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1"; EmptyDataText="There are no data records to display." GridLines="Vertical"

...and remove the semicolon (;).

Thursday, August 16, 2007

Irrelevant Crap!

Thank you for participating in our beta test. Please tell us how we can improve Visual Studio for you

STOP INCLUDING IRRELEVANT CRAP IN THE HELP SEARCH RESULTS

Update!

Let's add THIS to the list of irritations while we're here!

Monday, August 6, 2007

Embedding CSharp output into a web page.

Ok, so I wanted to make a gallery page that reads every JPG in my /gallery path, and presents them in a page. So I tried to put a "placeholder" object, and fill it with stuff on C# code on Page_Load.

No Dice.

I tried a bunch of other things, but the only thing that worked was to use a Label component, and in the C#, set Label1.text to include all the HTML I wanted to embed in the page. The Label component seems to me to be an odd control to use for this. Is there a better way, or is this what labels are made for?

Here is the page.

Saturday, August 4, 2007

Error: Unrecognized attribute 'xmlns'. Note that attribute names are case sensitive

Visual Web Developer 2008 After publishing a newly created website to an existing server (after updating the .NET framework). I browse to the website from my workstation and get:

Error: Unrecognized attribute 'xmlns'. Note that attribute names are case sensitive

...in this file:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config

Here is what to do.

  1. Edit the web.config file (get the filename from the bottom of the error message) . Make sure you're opening the version on the SERVER, not your local workstation.
  2. find every occurrence of the text xmlns="", and DELETE it. Do NOT delete the line that has a long filename in the "" marks.
  3. Save.
  4. Go back to your workstation and refresh the browser.
After a long time, it refreshed for me. It was like the webserver had to re-initialize first. Then it started acting normally.

Friday, August 3, 2007

Ok, What am I doing wrong here...

My web page looks like this in my local machine:

So I "publish" it. to the webserver, which is 4 feet to the right.

Ok, let's go to the live website and compare to the test website...

Ok, Parser Error Message: Child nodes not allowed. What does that mean? Apparently there is an error in my web.config file, which I never touched... It was generated automatically from Visual Web Developer. From my decades of programming experience, I am estimating that it's because I need to add the beta version of the .NET library to my server. But why cant the error just say You have to upgrade to the latest version of the .NET Framework to view this page?

I am upgrading the server now (should take an hour). I will bet you that it requires a reboot and that there is still an error after the upgrade is complete.

Meanwhile, let's look for this error in the help system. Searching for <providerOption name="CompilerVersion" value="v3.5"/> Let's search the Help!

Nothing. Lets check the questions site... Oh this is nice: from this page:

That's why it's called a BETA there champ...It has bugs.

Real helpful there... Ok lets run this error by Google.

Ok, turning to Google.

There is a really good post here - it's a lot of reading but it seems like they have a handle on the problem. Why is there nothing about this on the Microsoft site? I can't believe they have never heard of this problem!

Visual Web Developer 2008: First Look

Last night after hours of downloading, I got the VWD 2008 beta! Cool. It is a little easier to use than 2005 and they have kept the ability to design great websites that will not deploy to your webserver. I would show you a screen snap of the beautiful site I designed, but this is what I got when I tried to load my project this morning.

--------------------------- Microsoft Visual C# 2008 Express Edition --------------------------- 'C:\Documents and Settings\Some_Yahoo\My Documents\Visual Studio 2008\WebSites\AFI2\' cannot be opened because its project type () is not supported by this version of Visual Studio. To open it, please use a version that supports this type of project.


I figured it out: I was trying to open the Visual Web Developer Solution file in Visual C# Express. Bonehead move!

Share This!

Contact Us

Name

Email *

Message *