Friday, September 25, 2009

Creating an ActiveX object and running it in a browser

I'm such an old fuddy duddy... that I'd never really tried COM wrapping on C# objects.

But today all that changed...

This blog post helped lots:

I'll try to actually post the code on this later... it's a nice way of extending a web app in an Intranet environment (it's not for Internet...)

Saturday, September 12, 2009

An excellent explanation of the confusion that reigns between ASP.Net 2.0 and 3.x

This is something I've come across more than once now - people complaining their ASP.Net 3.5 applications are running as 2.0 and not being able to set them in IIS...

Here's a superb explanation of what 3.0 and 3.5 added to 2.0 - and how they did it without changing the core runtime

Monday, September 07, 2009

Adding direct SQL editing/browsing access to any website...

I was editing a nopcommerce website that I only had http and ftp access to - no sql access.

So I needed a way to execute some SQL scripts.

To do this I added (to the administration pages) the following

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SQLRunner.aspx.cs" MasterPageFile="~/Administration/main.master" Inherits="NopSolutions.NopCommerce.Web.Administration.SQLRunner" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="server">
    <br />
    <asp:TextBox ID="tbSQL" runat="server" Columns="80" Rows="10" TextMode="MultiLine">
    <br />
    <asp:CheckBox ID="cbScript" runat="server" Text="Run as script" />
    <asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btnGo_OnClick" />
    <br />
    <asp:Panel ID="pnlOutput" runat="server" Visible="false">
        <asp:GridView ID="grdResults" runat="server"></asp:GridView>
    <asp:Label ID="lblResult" runat="server" >

coupled with this source

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NopSolutions.NopCommerce.Web;
using NopSolutions.NopCommerce.DataAccess;
using System.Configuration;
using System.Data.SqlClient;

namespace NopSolutions.NopCommerce.Web.Administration
    public partial class SQLRunner : BaseNopAdministrationPage
        protected void Page_Load(object sender, EventArgs e)


        protected void btnGo_OnClick(object sender, EventArgs e)
                var sqlConnection = NopSqlDataHelper.CreateConnection(ConfigurationManager.ConnectionStrings["NopSqlConnection"].ConnectionString);
                var sqlCommand = sqlConnection.GetSqlStringCommand(tbSQL.Text);
                if (cbScript.Checked)

                    pnlOutput.Visible = false;
                    var dataSet = sqlConnection.ExecuteDataSet(sqlCommand);

                    pnlOutput.Visible = true;
                    grdResults.DataSource = dataSet;
                lblResult.Text = "OK";
            catch (Exception exc)
                lblResult.Text = string.Format("Exception seen - {0} - {1}", exc.GetType().Name, exc.Message);

Seems to work OK :)

Some interesting projects on codeplex

Just did a quick troll through the list of some of the more popular projects on codeplex - just to see what was on there.

These are some of the things that caught my eye.

Cosmos - open source operating system for C# -

GPS Tracka - - looks good!
TravelPoint - windows mobile GPS location -

Silverlight Media Player -

Quick Query Editor -

A bit DNN Help desk module -
Some DNN SKins -

BugTracker.Net - and
CSharp Parser -
Code review -

Kigg - interesting site - and

CMS stuff - -
CMS stuff -
CRM project -
WikiPlex -

DinnerNow sample app -

Google Map control - and
Geo Framework -
Deep Earth - Silverlight mapping -
Google maps in winforms -

Thursday, September 03, 2009

ASP.Net AJAX problems - Gray Google Maps

While adding some google map functionality to a custom nopcommerce build I came across some "gray map of death" problems with the gmaps. Basically the maps seemed to be offline - they didn't draw properly and they didn't respond correctly to mouse events (double click or drag).

Searching, I found a few references to these sorts of problems - most of which seemed to be caused by css issues (float:left seemed to be a common cause).

However, eventually this thread showed me the way forwards -

Basically, the initialisation of my AJAX tabs was causing the google map to lose its positional information - so to reset it I needed to call map.checkResize() - which seemed to cure the problem :)