Thursday, April 10, 2014 #

Dynamically Load jQuery From Unobtrusive JavaScript Library

I am tasked with dynamically injecting jQuery into each page if it is not already loaded from an Unobtrusive JavaScript Library.

The normal way of injecting a script tag would be:

Code Snippet
  1. var jq = document.createElement('script');
  2. jq.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js';
  3. jq.onload = function () { initJQuery(); };
  4. var h = document.getElementsByTagName('head')[0];
  5. h.appendChild(jq);

 

However, this will never work on IE8 or IE7, because the .onload callback is never called.

So what is the [workaround]?

 

Code Snippet
  1. //============================================
  2. //Begin Dynamically load jQuery
  3.  
  4. if (typeof jQuery == 'undefined') {
  5.     //var jq = document.createElement('script');
  6.     //jq.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js';
  7.     //jq.onload = function () { initJQuery(); };
  8.     //var h = document.getElementsByTagName('head')[0];
  9.     //h.appendChild(jq);
  10.     //http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet/
  11.         (function () {
  12.             // more or less stolen form jquery core and adapted by paul irish
  13.             function getScript(url, success) {
  14.                 var script = document.createElement('script');
  15.                 script.src = url;
  16.                 var head = document.getElementsByTagName('head')[0],
  17.                     done = false;
  18.                 // Attach handlers for all browsers
  19.                 script.onload = script.onreadystatechange = function () {
  20.                     if (!done && (!this.readyState
  21.                          || this.readyState == 'loaded'
  22.                          || this.readyState == 'complete')) {
  23.                         done = true;
  24.                         success();
  25.                         script.onload = script.onreadystatechange = null;
  26.                         head.removeChild(script);
  27.                     }
  28.                 };
  29.                 head.appendChild(script);
  30.             }
  31.  
  32.             getScript('https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js', initJQuery);
  33.         })();
  34. }
  35. else {
  36.     initJQuery();
  37. }
  38.  
  39. //End ofDynamically load jQuery
  40. //============================================

And Voila!  Problem Solved!

Technorati Tags: ,,,, Windows Live Tags: Dynamically Load jQuery,Unobtrusive JavaScript Library,onload,IE8, and IE7,Code

Posted On Thursday, April 10, 2014 1:33 AM | Comments (0)

Monday, March 17, 2014 #

jQuery().ajax dataType: JSONP–Error Handler Not Called

I am tasked with using an external Web Service API from a different domain to return a JSON object using the dataType: JSONP.  

I am forced to use JSONP because it is a Cross Domain Request, and I am using an Unobtrusive JavaScript Library we host in the Azure Cloud.

Sporadically, I received an error (net::ERR_NETWORK_RESET).  There is an alternative external Web Service API from another domain that could provide similar results, but it’s reliability is potentially just as spotty.

The documentation for jQuery.ajax() specifically states in reference to the Error Handler:

Note: This handler is not called for cross-domain script and cross-domain JSONP requests.

The ajax call just fails gracefully.  That may be a behavior acceptable to you, but I needed more.

So what is the [workaround]?

The Timeout Handler is your friend!  You can specify timeout to trigger an error callback.  It means that within the specified time frame the request should be successfully completed. Otherwise, assume it has failed:

  1: $.ajax({
  2:     ...
  3:     timeout: 5000, // a lot of time for the request to be successfully completed
  4:     ...
  5:     error: function(x, t, m) {
  6:         if(t==="timeout") {
  7:             // something went wrong (handle it)
  8:         }
  9:     }
 10: });

And this is where the magic begins.    Within the Error Handler, you can use a nested jQuery.ajax() call.  Who knew?!  Yes, it was a surprise to me, too.

There are two Web Services out on the Internet that both return basically the same data.  The first one is my preferred Web Service, but is sporadically subject to network timeouts and resets. 

 

Here is the refactored code:

  1: jQuery.ajax({
  2:     url: 'http://someurl.com/',
  3:     dataType: 'JSONP',
  4:     timeout: 5000,
  5:     error: function (x, t, m) {
  6:         jQuery.ajax({
  7:             url: 'http://anotherurl.com/',
  8:             dataType: 'JSONP',
  9:             timeout: 2000,
 10:             error: function (x, t, m) {
 11:                 // Do stuff here
 12:             }
 13:         })
 14:             .success(function (data) {
 15:                 // Do stuff here
 16:             });  // end of success for NESTED jQuery.ajax call
 17:     } // end of error for OUTER jQuery.ajax call
 18: })
 19:     .success(function (data) {
 20:         // Do stuff here
 21:     }
 22:}); // end of success for OUTER jQuery.ajax call
 23: 

 

And voila!  Problem solved!

Technorati Tags: ,,,,,,,,,,,,

Windows Live Tags: JSONP,Error,Handler,Cross Origin Request,Unobtrusive JavaScript,JavaScript Library,Azure,ERR_NETWORK_RESET,Timeout,jQuery,ajax,dataType,callback

Posted On Monday, March 17, 2014 4:24 PM | Comments (0)

Wednesday, May 9, 2012 #

Inject Pixels Into DOM

I was tasked with adding various Tracking Pixels to the DOM from an Unobtrusive JavaScript Library hosted in the Azure Cloud.

It finally dawned on me that I did not have to go through the machinations of creating the pixel and appending it to the appropriate element in the DOM.

All I really needed to accomplish was to have the pixel fire (meaning: send an HTTP Request to a remote Server), complete with its Query String values, which each Server on the other side needs in order to process Server-Side-Code before returning the pixel.

It never matters whether the pixel actually appears on the page or not.  Delivering the payload is the only goal.

So what is the [workaround]?

I rethought the creation of pixels and opted for a very quick method of creating many pixels at the same time:

intermark.createImages = function () {
    for (var i = 0; i < arguments.length; i++) {
        var img = new Image();
        img.src = arguments[i].toString();
    }
};
 
And then I can call the function using the following for any number of pixels necessary:
if (id > -1) {
    intermark.createImages(pixel1Src, pixel2Src);
}
 
And Voila! Problem solved!

Posted On Wednesday, May 9, 2012 8:56 PM | Comments (0)

Wednesday, August 17, 2011 #

Google Analytics Cross Domain Not Working

After setting up the Cross Domain parameters properly, using _setDomainName(), _setAllowHash(), and _setAllowLinker(), and making sure to call the _trackPageview() last,  using ga_debug.js in Chrome, I was able to see that the AccountID and the SessionID were still changing upon navigating to the other Domain.

This meant the cookies were not being shared across the Domains using the _link() method from Google Analytics Asynchronous Library.

So what is the [workaround]?

After carefully studying how one would implement inline code to enable _link(), I realized I was missing a return false statement.  For inline code, the return false is used to prevent the Default Event of the anchor tag from occurring to the navigation source of the href attribute.  Using jQuery in an Unobtrusive JavaScript Library, without the return false statement, the _link() method just does not work:

$(‘a’).click(function () {
     var
href = $(this).attr(‘href’);
     if (href.indexOf(OtherDomainName) >  –1)  {
          _gaq.push([‘_link’, href]);

          return false;
     }
      return href;
});

And Voila!  Problem solved!

Windows Live Tags: Google Analytics,_link(),Cross Domain Tracking,Unobtrusive JavaScript

Posted On Wednesday, August 17, 2011 7:41 PM | Comments (1)

Sunday, August 22, 2010 #

Keeper of the history……….

For Colorado State Soccer Association (CSSA), I suddenly realize I have become “the Keeper of the history”!  People who have been involved with CSSA as long as I have (30 years) have either retired or passed away.

Okay, some historical facts:

CSSA was founded in 1939.  It started with 6 Men’s teams which were mostly “ethnic” teams sponsored by Restaurants.

Fred Ahmer of Vail, Colorado, convinced the late President Gerald Ford to become a Board Member of the Vail Valley Soccer Club.

One of Colorado’s own, Dr. Bob Contiguglia , more affectionately known as “Dr. Bob”, became President of US Soccer.  Dr. Bob has previously been the President of US Youth Soccer.  He had also founded Cherry Creek Soccer Association (now known as Storm), and had been President of Colorado Youth Soccer Association (CSYSA, now known as CYS).  Dr. Bob played college ball at Columbia University in New York, and then played on adult teams for Colorado State Soccer Association (CSSA).  Jon DeStefano and Ed Eid both served on his election committee when he ran for US Soccer President.

This logo was designed by my late husband, Edward Eid:

cssalogo - click to see full picture

It is an awesome logo, which captures the “spirit of the mountains”, which is Colorado!

However, what people don’t know is that Ed was born in Cairo, Egypt, and came to the United States in 1958.  Those four “mountains” actually represent the four pyramids of Giza.  Ed had many fond memories of climbing the pyramids, and of racing horses across the desert towards the pyramids.  When he came to Colorado, he fell in love with the mountains.  His love of the pyramids and of the Colorado mountains was synonymous!

I later changed the logo somewhat, with Ed’s approval, for publishing on the Web in 1997 to:

cssalogo2 - click to see full picture

Edward Eid was a member of the Colorado State Soccer Association BOT from 1985 until 1997 when he assumed the General Manager position (which he held until his death in 2006).  While on the CSSA BOT, Ed held almost every position, including President.  He was also Vice-President of Region IV for USASA.  He also owned a professional soccer team that won many national championships, the Colorado Comets.  In 1986 the Colorado Comets played the Canadian National Team and barely lost 2-1 to them at the Air Force Academy in Colorado Springs.  The Canadian National  Team was doing high altitude training in Colorado Springs in preparation for the upcoming World Cup in Mexico City.

April Heinrichs, former US Women’s Head Coach, and Captain of the first Women’s World Cup Championship team, played on Ed’s Bandits Youth Team.  Ed and April are both in the Colorado Soccer Hall of Fame.

In 1991 Ed Eid took two separate soccer teams on two separate trips to the then Soviet Union.  The first trip also included a stop in Belgrade Yugoslavia to see the Partisans play Red Star.  One of the soccer players in that first trip was Chino Melendez.  The very next year both the Soviet Union and Yugoslavia ceased to exist as nations.  Ed was given a citation by the Soviet Union and by his native country of Egypt as being “An Ambassador of Peace for Soccer”.  One of Ed’s favorite sayings was, “What is the first thing that breaks out when war stops around the world?  It’s not peace, because that takes awhile.  It’s a soccer game.”

After Ed’s death at the World Cup in Munich, Germany, in 2006, Senator Ken Salazar of Colorado read, on the floor of the US Senate, a tribute to Ed into the Congressional Record praising him for his efforts towards peace using the vehicle of soccer.

There is so much more!

Technorati Tags: ,,

Posted On Sunday, August 22, 2010 5:13 PM | Comments (0)

Sunday, December 13, 2009 #

Dynamically change Body Background-image!

What if you need to dynamically change the Body Background-image based on whether the Page IsPostback?  You have a CSS Stylesheet for the page, and that Stylesheet has a background-image defined for the body tag.

So what is the [workaround]?

You first must define the body tag on the page as a server control.  Then you can access the body control via code in your page:

  1: protected void Page_Load(object sender, EventArgs e)
  2: {
  3: 	if (!IsPostBack)
  4:         {
  5:             var rnd = new Random();
  6:             // the background images are incrementally named: background1,png, background2.png, etc.
  7:             // the Random number is seeded with 1 and the maxNum is (the number of background images + 1)
  8:             int rndInt = rnd.Next(1,4);
  9:             string imagePath = String.Format("background-image: url('../../images/background{0}.png')", rndInt);
 10:             // the body tag on the aspx page must be: <body id="body1" runat="server">
 11:             this.body1.Attributes.Add("style", imagePath);
 12:         }
 13:         else
 14:         {
 15:             // this will revert back to the background image defined in the stylesheet    
 16:             this.body1.Attributes.Remove("style");
 17:         }
 18: }

And Voila!  Problem solved!

Posted On Sunday, December 13, 2009 5:11 PM | Comments (0)

Friday, October 9, 2009 #

ReportViewer local – rdlc – handle subreports with multiple pages and parameters

 
  1: using System;
  2: using System.Collections;
  3: using System.Configuration;
  4: using System.Data;
  5: using System.Linq;
  6: using System.Web;
  7: using System.Web.Security;
  8: using System.Web.UI;
  9: using System.Web.UI.HtmlControls;
 10: using System.Web.UI.WebControls;
 11: using System.Web.UI.WebControls.WebParts;
 12: using System.Xml.Linq;
 13: using Microsoft.Reporting.WebForms;
 14: using Rpt = SchoolDistrict.Registration.Reports; 
 15: 
 16: public partial class Reports_RegistrationReport : System.Web.UI.Page
 17: {
 18:     protected void Page_Load(object sender, EventArgs e)
 19:     {
 20:         //Workaround to allow the horizontal scroll bar to show.
 21:         //http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2803199&SiteID=1
 22:         ReportViewer1.Style.Add("margin-bottom", "26px");
 23:     }
 24:     /// <summary>
 25:     /// Event handler for the btnGenerateReport_Click event
 26:     /// </summary>
 27:     /// <param name="sender"></param>
 28:     /// <param name="e"></param>
 29:     protected void btnGenerateReport_Click(object sender, EventArgs e)
 30:     {
 31:         SetSchoolAndClassSessionKeys();
 32:         this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing);
 33:         ReportViewer1.LocalReport.Refresh();
 34:     } 
 35: 
 36:     void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e)
 37:     {
 38:         int schoolID;
 39:         string schoolName;
 40:         int classID;
 41:         string className;
 42:         //Converts SessionKeys to appropriate values to pass to methods
 43:         GetSchoolAndClassSessionKeys(out schoolID, out schoolName, out classID, out className); 
 44: 
 45:         //Determines which SubReport is being processed
 46:         int reportPath = GetSubReportPathCase(e); 
 47: 
 48:         switch (reportPath)
 49:         {
 50:             case 1:
 51:                 e.DataSources.Add(new ReportDataSource("Registration", new Rpt.ReportManager().GetRegistrationRecordPctBySchool(
 52:                     schoolID, schoolName, classID, className)));
 53:                 break;
 54:             case 2:
 55:                 e.DataSources.Add(new ReportDataSource("Registration", new Rpt.ReportManager().GetRegistrationRecordPctBySchoolDistrict(
 56:                     schoolID, schoolName, classID, className)));
 57:                 break;
 58:             case 3:
 59:                 e.DataSources.Add(new ReportDataSource("Registration", new Rpt.ReportManager().GetRegistrationRecordComments(
 60:                     schoolID, schoolName, classID, className)));
 61:                 break;
 62:             default:
 63:                 break;
 64:         }
 65:         ////Guru's code
 66:         //e.DataSources.Add(new ReportDataSource("Registration", new Rpt.ReportManager().GetRegistrationRecord(
 67:         //    int.Parse(Session["SchoolNameKey"].ToString()),
 68:         //    Session["SchoolName"] as string, int.Parse(Session["ClassNameKey"].ToString()),
 69:         //    Session["ClassName"] as string))); 
 70: 
 71:         //throw new NotImplementedException();
 72:         //ReportViewer1.LocalReport.Render("PDF",
 73:     } 
 74: 
 75:     /// <summary>
 76:     /// Determines which SubReport is being processed
 77:     /// </summary>
 78:     /// <param name="e"></param>
 79:     /// <returns></returns>
 80:     private static int GetSubReportPathCase(SubreportProcessingEventArgs e)
 81:     {
 82:         //Determines which SubReport is being processed
 83:         int reportPath = 0; 
 84: 
 85:         if (e.ReportPath == "PctBySchool")
 86:         {
 87:             reportPath = 1;
 88:         }
 89:         else if (e.ReportPath == "PctBySchoolDistrict")
 90:         {
 91:             reportPath = 2;
 92:         }
 93:         else if (e.ReportPath == "Comments")
 94:         {
 95:             reportPath = 3;
 96:         }
 97:         else
 98:         {
 99:         }
100:         return reportPath;
101:     } 
102: 
103:     /// <summary>
104:     /// Converts SessionKeys to appropriate values to pass to methods
105:     /// </summary>
106:     /// <param name="schoolID">passed in as 0</param>
107:     /// <param name="schoolName">passed in as empty string</param>
108:     /// <param name="classID">passed in as 0</param>
109:     /// <param name="className">passed in as empty string</param>
110:     private void GetSchoolAndClassSessionKeys(out int schoolID, out string schoolName, out int classID, out string className)
111:     {
112:         //Converts SessionKeys to appropriate values to pass to methods
113:         int badValue; 
114: 
115:         if (int.TryParse(Session["SchoolNameKey"].ToString(), out badValue))
116:         {
117:             schoolID = int.Parse(Session["SchoolNameKey"].ToString());
118:         }
119:         else
120:         {
121:             schoolID = 0;
122:         } 
123: 
124:         schoolName = Session["SchoolName"].ToString(); 
125: 
126:         if (int.TryParse(Session["ClassNameKey"].ToString(), out badValue))
127:         {
128:             classID = int.Parse(Session["ClassNameKey"].ToString());
129:         }
130:         else
131:         {
132:             classID = 0;
133:         } 
134: 
135:         className = Session["ClassName"].ToString();
136:     } 
137: 
138:     /// <summary>
139:     /// Method to Set or Reset the Session Keys for the School/Class based on the values in two
140:     /// Ajax Cascading Drop-Down Lists.
141:     /// </summary>
142:     private void SetSchoolAndClassSessionKeys()
143:     {
144:         if (!((string.IsNullOrEmpty(ddlSchoolName.SelectedValue)) || (string.IsNullOrEmpty(ddlClassName.SelectedValue))))
145:         {
146:             Session[ReportKeys.SchoolNameID] = ddlSchoolName.SelectedValue;
147:             Session[ReportKeys.SchoolName] = ddlSchoolName.SelectedItem.ToString();
148:             Session[ReportKeys.ClassNameID] = ddlClassName.SelectedValue;
149:             Session[ReportKeys.ClassName] = ddlClassName.SelectedItem.ToString(); 
150: 
151:         }
152:         else
153:         {
154:             Session[ReportKeys.SchoolNameID] = string.Empty;
155:             Session[ReportKeys.SchoolName] = string.Empty;
156:             Session[ReportKeys.ClassNameID] = string.Empty;
157:             Session[ReportKeys.ClassName] = string.Empty; 
158: 
159:             //ReportViewer1.LocalReport.Refresh();
160:         }
161:     } 
162: 
163:     /// <summary>
164:     /// Event Handler for the ReportViewer1 Refresh Button
165:     /// </summary>
166:     /// <param name="sender"></param>
167:     /// <param name="e"></param>
168:     protected void ReportViewer1_ReportRefresh(object sender, System.ComponentModel.CancelEventArgs e)
169:     {
170:         btnGenerateReport_Click(sender, e);
171:     }
172: } 
173: 
And Voila!
Technorati Tags: ,,,,,,

Posted On Friday, October 9, 2009 12:46 AM | Comments (0)

Sunday, September 13, 2009 #

ReportViewer local - Add a line number to the .rdlc textbox

//Add a line number to the .rdlc textbox: use this formula
=RowNumber(nothing)

//ReportViewer Conditional Formatting of BorderStyle based on whether anything is in the report.
=iif(CountRows()=0,"None","Solid")
=iif(CountRows()=0,"None","Dashed")
=iif(CountRows()=0,"None","Dotted")

//ReportViewer Conditional Formating and showing the Avg if there are rows in the report.
=iif(CountRows()=0,"",(Avg(Fields!PctDisb.Value) & "%"))

textbox:
name: PageXofY
="Page " & Globals.PageNumber & " of " & Globals.TotalPages

page footer not being displayed in excel export of reportviewer
http://forums.msdn.microsoft.com/en-US/vsreportcontrols/thread/0ead9e34-bc45-4062-90dd-17f8f8ebf062/

PctOfTotal
=(Fields!EOM_Total.Value)/(Sum(Fields!EOM_Total.Value))
=iif((CStr(Fields!EOM_Total.Value/ReportItems!SumEOM.Value)="NaN"),0,(Fields!EOM_Total.Value/ReportItems!SumEOM.Value))

Sum of PctOfTotal
=Sum((Fields!EOM_Total.Value)/(Sum(Fields!EOM_Total.Value)))

=Fields!PctOfTotal.Value
=ReportItems!PctValue.Value

And Voila!

Posted On Sunday, September 13, 2009 7:03 PM | Comments (2)

Implement handlers for the DataGridView control's CellValidating and CellEndEdit events.

The CellValidating event handler is where you determine whether the value of a cell in the SchoolName column is empty. If the cell value fails validation, set the Cancel property of the System.Windows.Forms.DataGridViewCellValidatingEventArgs class to true. This causes the DataGridView control to prevent the cursor from leaving the cell. Set the ErrorText property on the row to an explanatory string. This displays an error icon with a ToolTip that contains the error text. In the CellEndEdit event handler, set the ErrorText property on the row to the empty string. The CellEndEdit event occurs only when the cell exits edit mode, which it cannot do if it fails validation.

private void dataGridView1_CellValidating(object sender,
    DataGridViewCellValidatingEventArgs e)
{
    // Validate the SchoolName entry by disallowing empty strings.
    if (dataGridView1.Columns[e.ColumnIndex].Name == "SchoolName")
    {
        if (String.IsNullOrEmpty(e.FormattedValue.ToString()))
        {
            dataGridView1.Rows[e.RowIndex].ErrorText =
                "Company Name must not be empty";
            e.Cancel = true;
        }
    }
}

void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
    // Clear the row error in case the user presses ESC.  
    dataGridView1.Rows[e.RowIndex].ErrorText = String.Empty;
}

And Voila!

Posted On Sunday, September 13, 2009 6:53 PM | Comments (0)

Tuesday, September 8, 2009 #

Entity Framework and Join Tables.

I had a true join table (two foreign keys which, together, were a composite key in the join table).  I followed the steps enumerated in Julie Lerman’s Blog Don't Be Iffy and got unexpected behavior.  I was not only inserting new rows where they belonged, but was adding to one of the tables with the foreign key!  Not good!

Since she is the “go-to-Guru” I was baffled!  Then I realized the issue, and used Julie’s Platinum Rule to solve the problem: “The Platinum Rule is that an object graph (for example when a customer is attached to an order which is attached to some line items) must be completely in or completely outside of the ObjectContext.”

Briefly, the Use Case went something like this:  School District personnel needed to register students into different schools.  However, they needed the flexibility to pause those registrations at any time, and then to pick up where they left off.  The students would not become part of the “real” tables in the database until all of that students registration information was complete.  As a DBA, I built a “side-by-side” infrastructure, and only when the finish button was pushed would I move the paused student over to the “real” tables.

I had tables and Entity Framework entities called:
Student
School
SpecialCircumstance
PausedStudent
PausedSchool

In addition, I had two join tables (for each join table: two foreign keys which, together, were a composite key in the join table).:
SchoolSpecialCircumstance
PausedSchoolSpecialCircumstance

These two join tables don’t show up as entities, but Navigation Properties in each of the foreign key entities.  So, in other words, PausedSchool had a NavigationProperty called SpecialCircumstance, and School had a NavigationProperty called SpecialCircumstance.  Likewise, SpecialCircumstance had two NavigationProperties, one called School and one called PausedSchool.

When the finish button was clicked I should have had one new row in SchoolSpecialCircumstance that had a FK to School and a FK to SpecialCircumstance.  That row was successfully inserted.  HOWEVER, in addition, I had a new row in SpecialCircumstance with a new ID number, which was the same ID number as the FK in SchoolSpecialCircumstance.  Not acceptable!  The SpecialCircumstance were a finite list of pre-defined items, and this was in effect duplicating that data.

The issue arose because I was adding objects to the School object, which had a FK to the Student object.  At the end of this “chaining” I called AddToStudent on the ObjectContext so that all the FKs were populated correctly:

newSchool.otherObject.Add(newObject);
newSchool.anotherObject.Add(newAnotherObject);
newSchool.SpecialCircumstance.Add(newSpecialCircumstance);
newStudent.School.Add(newSchool);
ctx.AddToStudent(newStudent);
ctx.SaveChanges();

So what is the [workaround]?  The ObjectContext has to know about the FK relationships before it can do anything with them!

newSchool.otherObject.Add(newObject);
newSchool.anotherObject.Add(newAnotherObject);
newStudent.School.Add(newSchool);
ctx.AddToStudent(newStudent);

newSchool.SpecialCircumstance.Add(newSpecialCircumstance);

ctx.SaveChanges();

And Voila!  Problem solved!  Just goes to prove that “timing is everything in this world!”

Posted On Tuesday, September 8, 2009 5:02 PM | Comments (0)

Sunday, September 6, 2009 #

Error: conversion of a datetime2 data type to a datetime data type…

Using VS2008 and Entity Framework, the exact error message is:
"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."

There are several causes for this rather generic (and not very intuitive) error message.

I had changed some fields in the SQL 2008 database from non-nullable to nullable, and then asked the tool to “update model from database”.  The error message appeared in that instance because one part of the ADO.NET Entity Data Model does not automatically get updated when this happens.  The ADO.NET Entity Data Model has three parts:
SSDL (Store Schema Definition Language)
CSDL (Conceptual Schema Definition Language)
MSL (Mapping Schema Language)

So what is the [workaround]?

The SSDL and the MSL update just fine, but I had to “hand-code” the changes in the CSDL.

And Voila!  Problem solved!

Posted On Sunday, September 6, 2009 5:01 PM | Comments (1)

…Session state can only be used when enableSessionState is set to true…

I am using VS2008 in a Vista Ultimate environment.  Here is the complete error message:
”Exception Details: System.Web.HttpException:  Session state can only be used when enableSessionState is set to true,
either in a configuration file or in the Page directive.  Please also make sure that System.Web.SessionStateModule or a
custom session state module is included in the “<configuration>\<system.web>\<httpModules> section in the application configuration.”

NONE of that was the problem!  I even verified that SessionState was running as a service, which it was!

Okay, what is the [workaround]?

Navigate to:
Control Panel > Programs > Turn Windows features on or off

When that dialog-box finishes loading, expand:
Internet Information Services > Web Management Tools > IIS 6.0 Management Compatibility

Make sure the following two check-boxes are checked:
IIS 6 WMI Compatibility
IIS Metabase and IIS 6 configuration compatibility

And Viola!  Problem solved!  That was a two-hour ordeal for our team!  Hope I saved you some time!

Posted On Sunday, September 6, 2009 5:00 PM | Comments (2)

How to force update of Intellisense without opening and closing a file in Visual Studio 2008?

In Visual Studio 2008, I periodically see the error in the status bar:
”Error updating JScript Intellisense, see Error list”

HOWEVER, there are no errors about this in the Error list!  And, the site compiles, runs, and publishes perfectly!  Total annoyance!

I believe this is an error caused by the inclusion of the JQuery library and some inability of the Intellisense parser to “play nice in the playground”.

Okay, so what’s the [workaround]?

You can force an update of Intellisense with the following keyboard-shortcut:

Ctrl + Shift + J

And Voila!  Problem Solved!  Annoyance gone!

Posted On Sunday, September 6, 2009 5:00 PM | Comments (0)

Wednesday, August 26, 2009 #

Colorado Rapids Suffering from "”Mysterious White Box Syndrome”…

As you can see from the screen-shots below, the syndrome may be fatal to their Website!

Rapids_WhiteBoxSyndrome

Figure 1

In Figure 1, notice the prominent white-box (which is supposed to be a menu drop-down list) covering the player in the white uniform. 

Rapids_WhiteBoxSyndrome_picutre2

Figure 2

In Figure 2, the box is wider and over to the right, covering advertising above the calendar schedule.

How in the world did the Colorado Rapids become sick with this Mysterious White Box Syndrome?  Well, I’m glad you asked!  No, really, I am!  Can’t you hear me smiling?!

The cause of this “contracted” illness is a well known issue with IE8 (Internet Explorer 8) and the dynamic menu items of the menu control.  Viewing the source, it’s obvious that the programmers used Visual Studio.  They could have easily seen this problem during the debug cycle with IE8 installed (unless they made the “less than professional” mistake of running IE8 in compatibility mode – don’t develop in that mode).  You always need to test your code for cross-browser compatibility.

The [workaround] for this problem is a simple CSS (Cascading Style Sheet) Z-Index fix:

/* this is the [workaround] for asp:menu IE8 Dynamic menu items not showing */
.adjustedZIndex
{
    z-index:1;
}

And voila!  Disease cured!  I think that [workaround] is worthy of a nomination by the Nobel Committee for Medicine, don’t you?!

Do you think someone should let them know?

Now, if only I had a cure for what ails them on the soccer field!!  That would be a miracle!

Posted On Wednesday, August 26, 2009 4:58 PM | Comments (0)

Monday, August 24, 2009 #

Do the Colorado Rapids deserve your money….?

In this economy, I THINK NOT!

That is a very difficult conclusion for me to come to!  After all, I was the Rapids very First Webmaster for the first two years of their existence (for very little compensation) in 1995 thru 1997.  My late husband sold more Rapids tickets (without commission) than any of the original sales force.

But that was 14 long years ago!  They have never been a contender in the MLS and I see nothing happening to change that.

There seems to be an air of arrogance from the management on down to the playing field.  The players certainly have no justification for arrogance!  Quite frankly you can see better soccer at the Youth games.  In the days of the previous ownership and management, there was a sense of approachability.  Not now!

They are pressuring me to renew my Club Season Tickets (at $60 each/game).

But in this economy…I THINK NOT!

Technorati Tags:

Posted On Monday, August 24, 2009 12:34 AM | Comments (0)

Sunday, August 23, 2009 #

Tips and Tricks – Windows Live Writer (WLW)

  1. The “normal” windows keyboard shortcuts of Ctrl+Z (undo), Ctrl+Y (redo), and Shift+Enter (new paragraph inside of bulleted/numbered items like these) work great in WLW.
  2. I had a few “Recently posted” items, from failed posts still hanging around in the right sidebar.  When I tried to click on them, I got an error message.  Very frustrating, and I wanted them gone!  If there are enough “Recently posted” items, you can just click on the More… folder link at the bottom of that section, and it opens a dialog box which gives you the option to delete them.  However, after deleting a few, I closed out of that dialog box while still having more to delete.  Suddenly, there was no More… folder link to click on!  Grrrrrr! 
    The [workaround] is that you can navigate to your Documents > My Weblog Posts > Recent Posts folder.

     090130_Blog_ScreenShot_1

    You will find the various posts in question listed.  There is an XML file called cache.xml.  I edited the cache.xml file in notepad (after making a backup copy of it, of course), and then deleted the files in question.  Fortunately for me, they all had the same title, with a different date and time.  They were appended with, [2], [3], and [4].  I needed the last one posted (by time).  The time in the XML file corresponded, and thus I was able to delete the correct ones.  Viola!  No more nagging artifacts hanging around!
Technorati Tags: ,

Posted On Sunday, August 23, 2009 4:57 PM | Comments (0)

Saturday, August 23, 2008 #

Finally decided to Blog…

I am the Geek who has resisted Blogging for so long,, but now I am going  to take the plunge!

Hopefully the waters will remain calm and tranquil, no matter what topics I choose!

HumorWomanBuriedByPaperwork

Posted On Saturday, August 23, 2008 10:07 PM | Comments (0)

Copyright © intermark

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski