Search

just show me the code

Friday, October 31, 2008

Omniture Tracking with Flash

/* START: Omniture ActionSource Configuration*/
import com.omniture.AS2.ActionSource;
var s;
function configActionSource() {
    s = new ActionSource();
    /* Specify the Report Suite ID(s) to track here */
    s.account = "XXXX";
    /*You may add or alter any code config here: see documentation for more variables
    */
    s.pageName = "Sample App d1.2: State 1";
    s.pageURL = "";
    s.charSet = "ISO-8859-1";
    s.currencyCode = "USD";
    /* Turn on and configure ClickMap tracking here */ 
    s.trackClickMap = true;
    s.movieID = "sample_dynamic_object_1_2";
    /* Turn on and configure debugging here */
    s.debugTracking = true;
    s.trackLocal = true;
    /* WARNING: Changing any of the below variables will cause drastic changes
    to how your visitor data is collected. Changes should only be made
    when instructed to do so by your account manager.*/
    s.dc = 112;
    /* onLoad Transaction*/
    s.delayTracking = 500;
    // half second delay for tracking after load
    s.track();
}
configActionSource();
/* END: Omniture ActionSource Configuration*/

open up fiddler and watch your tracking


Thursday, October 30, 2008

Keep the scrollbar

html { height: 100%; margin-bottom: 1px; }

if you have a centered and the page is too short for a scroll bar, when it gets longer the scroll bar appears and you page shifts the left a few pixels. This post will help you avoid that problem.
http://www.hicksdesign.co.uk/journal/forcing-scrollbars-now-even-better

bind a gridview column to a method

bind a attribute of the ItemTemplate to a method

<asp:TemplateField HeaderText="Deleted Ind" SortExpression="DeletedInd"> 
    <ItemTemplate>
        <asp:CheckBox ID="cbDeletedInd" runat="server" 
            Checked='<%# this.GetNullableBool(Eval("DeletedInd"))  %>' 
            Enabled="false" />
    </ItemTemplate>
</asp:TemplateField>


put the method in your codebehind (this could be a bind utility method)

protected bool GetNullableBool(object o)
{
    bool bReturn = false;
    Nullable<bool> b = o as Nullable<bool>;
    if (b != null)
    {
        if (b == true)
        {
            bReturn = true;
        }
    }
    return bReturn;
}


this method returns false if the bool is false or null
otherwise it returns true

now we use the RowDataBound to format that row


protected void gvResults_RowDataBound(object sender, GridViewRowEventArgs e)
{ 
    CheckBox c = (CheckBox)e.Row.FindControl("cbDeletedInd");
    if (c != null && c.Checked)
    {
        e.Row.ForeColor = System.Drawing.Color.LightGray;
    } 
}


results: (the deleted rows are now grey)


creating change scripts in SQL Server Management Studio

when you change the schema of a database, Management Studio makes it easy to create your change script.

first make your change.
then click the generate script button





now you can save it to a sql script file.



this is what the file looks like. notice when you reorder the columns it creates a temporary table copies all the data. drops the original table, then creates the new table with the right column order. the copies the data back to the new table.


/*
   Thursday, October 30, 20088:49:47 AM
   User: 
   Server: stpdev
   Database: ODFL
   Application: 
*/
 
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the context of the database designer.*/
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.tblEmailType
    DROP CONSTRAINT DF_tblEmailType_LeadDays
GO
ALTER TABLE dbo.tblEmailType
    DROP CONSTRAINT DF_tblEmailType_SendToNonRegistered
GO
ALTER TABLE dbo.tblEmailType
    DROP CONSTRAINT DF_tblEmailType_PostEvent
GO
ALTER TABLE dbo.tblEmailType
    DROP CONSTRAINT DF_tblEmailType_active
GO
ALTER TABLE dbo.tblEmailType
    DROP CONSTRAINT DF_tblEmailType_time_stamp
GO
CREATE TABLE dbo.Tmp_tblEmailType
    (
    EmailTypeID int NOT NULL IDENTITY (1, 1),
    Name nvarchar(50) NOT NULL,
    LeadDays int NULL,
    ExactTargetTemplate nvarchar(255) NULL,
    SendToRegistered bit NOT NULL,
    PostEvent bit NOT NULL,
    active bit NULL,
    MyNewColumn nchar(10) NULL,
    time_stamp smalldatetime NULL
    )  ON [PRIMARY]
GO
ALTER TABLE dbo.Tmp_tblEmailType ADD CONSTRAINT
    DF_tblEmailType_LeadDays DEFAULT ((0)) FOR LeadDays
GO
ALTER TABLE dbo.Tmp_tblEmailType ADD CONSTRAINT
    DF_tblEmailType_SendToNonRegistered DEFAULT ((0)) FOR SendToRegistered
GO
ALTER TABLE dbo.Tmp_tblEmailType ADD CONSTRAINT
    DF_tblEmailType_PostEvent DEFAULT ((0)) FOR PostEvent
GO
ALTER TABLE dbo.Tmp_tblEmailType ADD CONSTRAINT
    DF_tblEmailType_active DEFAULT ((1)) FOR active
GO
ALTER TABLE dbo.Tmp_tblEmailType ADD CONSTRAINT
    DF_tblEmailType_time_stamp DEFAULT (getdate()) FOR time_stamp
GO
SET IDENTITY_INSERT dbo.Tmp_tblEmailType ON
GO
IF EXISTS(SELECT * FROM dbo.tblEmailType)
     EXEC('INSERT INTO dbo.Tmp_tblEmailType (EmailTypeID, Name, LeadDays, ExactTargetTemplate, SendToRegistered, PostEvent, active, time_stamp)
        SELECT EmailTypeID, Name, LeadDays, ExactTargetTemplate, SendToRegistered, PostEvent, active, time_stamp FROM dbo.tblEmailType WITH (HOLDLOCK TABLOCKX)')
GO
SET IDENTITY_INSERT dbo.Tmp_tblEmailType OFF
GO
ALTER TABLE dbo.tblUserEventEmail
    DROP CONSTRAINT FK_tblUserEventEmail_tblEmailType
GO
DROP TABLE dbo.tblEmailType
GO
EXECUTE sp_rename N'dbo.Tmp_tblEmailType', N'tblEmailType', 'OBJECT' 
GO
ALTER TABLE dbo.tblEmailType ADD CONSTRAINT
    PK_tblEmailType PRIMARY KEY CLUSTERED 
    (
    EmailTypeID
    ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.tblUserEventEmail ADD CONSTRAINT
    FK_tblUserEventEmail_tblEmailType FOREIGN KEY
    (
    EmailTypeID
    ) REFERENCES dbo.tblEmailType
    (
    EmailTypeID
    ) ON UPDATE  NO ACTION 
     ON DELETE  NO ACTION 
 
GO
COMMIT


Tuesday, October 28, 2008

printing using javascript

This script will bring up the print dialog on load of a web page.
<body class="" onLoad="self.print()"> 
thanks to Ian for the tip.

Sunday, October 26, 2008

get value in JQuery

you can see it in action here
you can download the code here

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript" src="scripts/jquery.js"><script>
        <script type="text/javascript">
            $(function() {
                $("#display").click(function() {
                    var o = $("#input");
                    var s = o[0].value;
                    //alert(s);
                    var o2 = $("#output")
                    o2.val(s);
                });
            });
        <script>
    <head>
    <body>
        <input id="input" type="text" value="" />
        <button id="display">display<button>
        <input id="output" type="text" value="" />
    <body>
<html>



Contributors