Coding mistakes

Monday, June 27, 2005

MachineName\ASPNET

Implementing a simple SQL insert in ASP.NET today, had a little problem writing to the DB at first. After adding ASPNET account to the users for the DB in SQLServer Enterprise Manager and giving it DataReader and DataWriter permission, everything works fine.

http://weblogs.asp.net/coltk/archive/2003/07/10/9920.aspx

Saturday, June 25, 2005

using mx.events.EventDispatcher

If I am using the EventDispatcher class in mx.events, must I always make my class dynamic so it can be assigned the methods?

Answer: You can do the following if you don't want to use dynamic (which is better) so Flash can resolve it at compile time.

private var addEventListnener:Function;
private var removeEventListener:Function;
private var dispatchEvent:Function

Saturday, June 04, 2005

Mach II framework

Spent quite a bit of time today to get things set up. I keep running into weird issues with it.

Here is what I found:

MachII needs to be installed in a folder that is pointed to in your custom path.
So if you put it in c:\Websites\MachII, then the custom search path should be c:\Websites.

Don't count on the component being discovered via current directory (that is, don't install it in the directory where your webpages reside). It won't work because some nested components are still referencing it. So basically it relies on an absolute pathing component name resolution.

Also, JRun seems to keep referencing the old component even after you change path (probably cached somewhere). It didn't become clear until after I turned on the debugging. Anyways, the only way I found to get the JRun server pick up the new changes when I move MachII folder around is to restart JRun. Update: Changing the mach-ii.xml is enough to force a config reload, which will in turn recreate the application objects.

Be sure to turn off the caching while developing code so JRun picks up the new changes too.

Install it in a central location somewhere so all MachII application will reference it.

Wednesday, June 01, 2005

Code behind

Server Error in '/ASPNET_Test2' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1595: 'Util.TempUtil2' is defined in multiple places; using definition from 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\aspnet_test2\491bfbd0\d1884c7\assembly\dl2\642f7e40\6e03d7f9_da66c501\ASPNET_Test2.DLL'

Reason: I was doing code behind:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="Util.TempUtil"
Src="Util.cs" %>

Fix: Set the Build Action for util.csfrom Compile to None.

Tip: The Codebehind attribute is only used by VS.NET, but by ASP.NET.

Monday, May 30, 2005

Event handler

Must you always call the base event handler (such as OnInit, OnLoad) when you are defining your own?

The size of a collection in .NET

While trying to display the # of controls on the page, I tried
Controls.size() (C++), Controls.length (java), but in .NET, it's Controls.Count().

Server Error in '/ASPNET_Test' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'F2C' does not exist in the class or namespace 'ASP.text_aspx'

Source Error:



Line 9:
Line 10: <%
Line 11: double C = F2C(20);
Line 12:
Line 13: Response.Write("Celsius: " + C);


Source File: G:\Websites\ASPNET_Test\text.aspx Line: 11


Reason: Missing runat for script block, causing the script block not to be included as a member in the autogenerated page-derived class.
Fix: