Sometimes C# just torques me off. Especially when it doesn’t give useful errors. I wrote the following line of code:
if (((string)e.Row.Cells[3].Value = "Yes")) {}
Which of course should have been:
if (((string)e.Row.Cells[3].Value == "Yes")) {}

The errors I got were:

The left-hand side of an assignment must be a variable, property or indexer

and

Cannot implicitly convert type 'string' to 'bool'

Why can’t it just say:

Hey stupid C#-wannabe former-VB.NET-programmer, you meant '=='.

Instead I spent 5 minutes trying different things before I noticed the typo.

D'oh!

Posted on January 26, 2006 in .NET. 2 comments

Another follow up to Removing an uninstalled .NET service, I ran into a problem where installutil kept giving me an error:
InstallUtil.exe is not a valid Win32 application. Annoying.

I found an post on Randomize that listed some of his(?) issues he saw when building a Windows Service. I think I was unable to unistall the service because of all the spaces in the path, but I seem to remember that I’ve always put my service in Program Files. That obviously has a space in it.

From Randimize’s link, I found another interesting article on how to get a description listed in the services console. I haven’t had an opportunity to try it out, but I will probably include it in the next windows service I need to build.

As it turns out, I’ll have to use my original technique of hacking the registry. Even after reinstalling the service, the problem was happening again.

Posted on January 14, 2006 in .NET. No comments (add one!)

In a followup to the previous post, the code listed there will work for user controls when they are located on the master page itself.

However, when the user control is the default content inside a placeholder, an extra .FindControl() needs to be done to get the placeholder, and then the user contol.

So if the user control is in the placeholder:

<asp:ContentPlaceHolder ID="Placeholder" runat="server">
<uc:ToolBar runat="server" id="Toolbar"/>
</asp:ContentPlaceHolder>

You need to reference it like this in the child page’s code-behind:
UserControls_ToolBar Toolbar = (UserControls_ToolBar) Page.Controls[0].FindControl("Placeholder").FindControl("Toolbar");

(hat tip: Jeffrey Palermo)

Posted on January 10, 2006 in .NET. 2 comments

Here’s a link to a list of all the events that fire in ASP.NET 2.0 page’s lifecycle.

http://weblogs.asp.net/jeff/archive/2004/07/04/172683.aspx

Posted on January 9, 2006 in .NET. No comments (add one!)

I love the idea of master pages in ASP.NET 2.0. They provide a standard look and feel for web applications that work much better than the old “include” model.

Sometimes it still makes sense to have a user control embedded in the master page. In particular, toolbars and navigation items may be reused across master and other non-master pages. Here’s how to access the user control on the master page:

On the child .aspx page, add the following:
<%@Reference Control="~/UserControls_Toolbar.ascx" %>

This allows the control to be referenced by the child.

In the code behind for the child you can now retrieve the object using:

UserControls_ToolBar Toolbar = (UserControls_ToolBar)Master.FindControl("Toolbar");

From there you can reference any properties on Toolbar as normal.

Its also recommended to create public property references on the master page for easier access to the user control (via Kiran Chand).

Posted on in .NET. 1 comment

Let’s say you have a .NET service you created. You built an installer that does a fine job of installing it, but you forgot to include the code to uninstall the service when the uninstaller runs. So you’ve uninstalled the executable, but it still appears in the Services Management Console. This makes a mess if you’re trying to install a new version.

What to do?

Well, go into regedit and back up the registry. Then, go to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

and find the name of your service. Deleting the service and a reboot will take care of the problem.

And next time, remember to use:

installutil.exe /u service.exe

Posted on January 3, 2006 in .NET. No comments (add one!)

« Previous Page   Later Entries »
Welcome !
Site google-analitix.com just created.

Real content coming soon.
© ISPmanager control panel