Pages

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!

Sunday, September 23, 2007

Microsoft! Please let the pain come to an end!

I have a website that sells a peice of software. My client wants to keep 90 seperate little pages, one for each little "feature" of the program. This is the perfect application for using a "web template", and store all these features into a database.

So, Lets set up the database first.

Piece of cake, right? so now, I need to get 90 of these pop-up windows into the datafields...

So I design a form for editing the data...

I can run the form, it shows my empty data table. I add a row and enter the small data, and then I cut/paste the feature window text into the "Feature Text" column.

Oh no! it only accepts the FIRST LINE of text! BUT WAIT! this is a "text" type, it should just KNOW that we want to put free-form text in here. Ok, so now I want to go into the properties of the FEATURE TEXT column and set Multiline to True.

What's this? There IS NO multiline property! Ok now lets hit the trusty F1 key.

After waiting an horribly long time, I search for Multiline Text Fields and nothing that comes back is relevant to what I'm trying to do.

Just to make the point come home a little better, I could solve this problem with Oracle and Delphi WITHOUT EVEN HAVING TO WRITE A PROGRAM! PL/SQL developer allows me to pop open a window on a CLOB (text) field and cut/paste/edit/whatever. This whole project would take about 15 minutes. BUT IN VISUAL STUDIO IT SEEMS TO BE IMPOSSIBLE!

Please, Microsoft! We beg you! Buy a copy of PL/SQL Developer and MAKE SQL SERVER WORK LIKE THAT!


Update: There IS a way... I will update on Friday! (Not this Friday, but "A" Friday)

Thursday, September 20, 2007

Oracle Options Missing from Visual Studio 2008 Express

Can someone please explain to me why the Oracle database connections are missing from the Visual Studio 2008 Express editions? Is this another iteration of "DOS ain't done till Lotus won't run?"

Or do I need to cough up blood to get Oracle fully supported in my development environment?


The rumor mill has it that the Oracle options are not included in the Express edition. I found this on several user forums, but I can't find any reference to it on the Microsoft site.

Hey Microsoft, what other options are missing from the express editions? Can I get a list?

Tuesday, September 18, 2007

Too Much

is anyone other than me tired of typing stuff like
System.Web.Lunch.Sandwich.Ham.Swiss.Rye myFood = new System.Web.Lunch.Sandwich.Ham.Swiss.Rye();
or
using Women;
girlFriend GirlFriend = new girlFriend();

Is it just me or is that way too much? No, really, I think we need the object type in there more times, just so the compiler really knows what's going on.

girlFriend GirlFriend = new girlFriend(girlFriend.girlFriend.create(girlFriend)) ;
There.

AAAAAAAH!

I found this great site that *almost* seemed to discuss what I want...

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/pages.aspx#serverctrls

But don't bother going there unless you want to do everything in Visual BASIC!

God Damn, Microsoft!

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!

Config Files: a primer

to use a config file in your project, first right-click the project name and Add a New Item:

pick Application Configuration File and give it a name:

Wednesday, August 15, 2007

Adding a printer

How to programmatically add a printer.

This will show how to add a printer to the current Windows workstation's Printers and faxes page. This will effectively render the printer usable by the workstation.

Here's the code example.

...
using System.Runtime.InteropServices;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        [DllImport("winspool.drv", SetLastError=true)]
        public static extern bool AddPrinterConnection(string pName);

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (AddPrinterConnection("\\\\PrintServer\\PrinterName"))
            { MessageBox.Show("ok"); }
            else
            {
                throw new Win32Exception();
            }
        }
    }
}

Splitting Strings without Regex

I have this string that I want to parse the server name out of. It looks like \\server-name\printer-name\. This turns out to be a piece of cake in C#, even without Regular Expressions. Here's the code.

 private void button1_Click(object sender, EventArgs e)
  {
      string[] parsed;
      parsed = textBox1.Text.Split(textBox2.Text[0]);
      listBox1.Items.Clear();
      if (parsed.Length == 4)
      {
          listBox1.Items.AddRange(parsed);
      }
      else
      { listBox1.Items.Add(parsed.Length.ToString() + " items found"); }      
  }
What happens here is that if the string conforms to the pattern \\server\printer, then it parses into the string array parsed. Here are some examples of how it works:

Easy, huh!

Sunday, August 12, 2007

Creating and Using Arrays in C#

Most of my history is with Borland/Inprise/Borland/CodeGear Delphi, so what I am trying to demonstrate is how to take a construct like these:

var
  States: array[0..49] of String[2];
  Counties: StringList;
begin
  Counties:=TStringlist.Create;

In this demo, States is an array of 50 string[2] variables indexed from 0. Counties is a re-sizable list of strings. A fixed array is a data type, while a TStringList is a class object. How do we do arrays in C#?

Here is an example of the declaration (and optional initialization) of a fixed array...

        public string[] States = new string[50] 
        {
            "AL","AK","AZ","AR",
            "CA","CO","CT",
            "DE",
            "FL",
            "GA",
            "HI",
            "ID","IL","IN","IA",
            "KS","KY",
            "LA",
            "ME","MD","MA","MI","MN","MS","MO","MT",
            "NE","NV","NH","NJ","NM","NY","NC","ND",
            "OH","OK","OR",
            "PA",
            "RI",
            "SC","SD",
            "TN","TX",
            "UT",
            "VT","VA",
            "WA","WV","WI","WY"
        };

Here is a collection, the equivalent of a Stringlist or TList.

        public ArrayList Counties = new ArrayList();

Now I'll pop some dialog messages to show we know what's in the array and in the collection... of course we have to first load something into the collection, so I created a button and wrote this code...

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("State 23 is " + States[23]);
            Counties.Add("Maricopa");
            Counties.Add("Sacramento");
            Counties.Add("Los Angeles");
            Counties.Sort();
            string temp = "";
            foreach (string S in Counties)
            {
                temp += S + "\n";
            }
            MessageBox.Show(temp);
        }

This code when compiled (after you resolve the missing using clause) gives this result...

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.

Another First (or last) from Microsoft!

Apparently Internet Explorer is the only browser in existence that still does not support transparent png graphics! Check this out from my test website over the weekend!

According to the wikipedia, I can solve this by reducing the png from 24 bit to indexed, effectively using it just like a gif.

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!

Wednesday, August 1, 2007

Downloading VS 2008

I downloaded VS 2008 today. It took about 3 minutes to download, then then just sat there for about 25 minutes installing. How could it take that much time, now that it was all on the local disk drive? Weird.

Furthering the weirdness, I am trying to remotely install the same thing on my dev machine from work, and every 10 seconds Norton pops up asking if the install can access the internet. So I can't set it running and forget about it, I have to sit here and monitor it.

Tuesday, July 31, 2007

Ch-ch-ch-chaaanges....

I renamed the blog from csharp journey to Visual Studio Journey because I also want to document my painful conversion to ASP.net as well as C#.

Sunday, June 24, 2007

Class

My company sent me to C# class last week. Hooray! I know that it will take a lot of trial and error to get it to work in my real-life projects, but I feel like I have a good grasp on the subject now.

The class was Microsoft's 2124C, which focuses on C# language fundamentals.

Damn Microsoft!

So I came home and started out fast... I created a C# class that reads a file and gives back a string. Piece o' cake, right? So I am in Visual Web Developer 2005 and how do I get the C# class to run and place it's text into my web page? Hmmm, there's no cool draggable object that will do it... there is no obvious tag that will do it. Do I have to encapsulate it with some kind of function? Shit! I'm stuck again...

Oh well, I'll have to come back to that problem later.

So I create a cool website in Visual Web Developer... It's not ready for primetime yet, but I decide to publish it to my webserver and watch the magic... You'll never guess what happened in a thousand years...

  • It worked normally, a site to behold!
  • It worked, but the formatting was slightly wrong in Firefox.
  • It had errors but after reading the helpful Microsoft error messages, I was able to get it online.
  • It refused to load, giving a server error message
  • It refused to load and refused to give an error message, citing security reasons.

Yep, it was that last one.

The error message I got was cryptic and it said if I edited my web.config file I would get a better answer. I edited the file and it gave the same result.

Next, I checked in the Error Log, and under the Application error section I found some stuff that led me to look for a file called machine.config. now machine.config is NOT in any directory you would look for it in, it's in C:\WINDOWS\Microsoft.NET\Framework\[your version of the .net framework]\CONFIG

The msdn help says to look in the %installdir%... directory, but install for WHAT? Ok, thank God for the bloggers!

So now I get to the part where it says to look in system.web under processModel and add a username="Something" and password="something". This article says Modify the username and Password attributes. Make sure you include the domain\username when appropriate.

Cool so I do that and get this:

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized attribute 'username'. Note that attribute names are case-sensitive.

Source Error:


Line 134:  </system.data>

Line 135:  <system.web>
Line 136:    <processModel username="XXXXXXXXXXXX" password="XXXXXXXXXX" autoConfig="true" />
Line 137:    <httpHandlers />

Line 138:    <membership>

Source File: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config    Line: 136


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

Ok, so I figured out that username should be userName, and I retry.

Perfect.

Oh, add to this the extra fun that whenever you edit machine.config you must restart IIS. But you can't shut off IIS because 5 other services are dependent on it. This means you must REBOOT the webserver after each and every attempt to fix the issue. I am at reboot 7 now, and as you can see from the screensnap, still unsuccessful.

If you want to see whether I have eventually made it (like a year from now) look at the test site. At the time of this writing, it's still refusing to work.

oooh, I got a new error:

Mind you, what I see in the Visual Web Developer Express is:

Well, the server needed 5 critical updates, so I installed them. Next I check the event log...

aspnet_wp.exe could not be started. The error code for the failure is 80004005. This error can be caused when the worker process account has insufficient rights to read the .NET Framework files. Please ensure that the .NET Framework is correctly installed and that the ACLs on the installation directory allow access to the configured account.

Since that whole crapfest I just went through was to grant ASP access to its directories, I guess that was all a waste of time.

It's late. I'm going home.

Share This!

Contact Us

Name

Email *

Message *