Display content of page in a modal dialog- consider jqModal.

I need to show popup info message with single close button, but content is located in separate html file. The current implementation using window.open not working for many users with popup blockers.
My question is which tool/framework should I use.
Initially I considered to use UFrame (see CodeProject article:UFrame: goodness of UpdatePanel and IFRAME combined )inside ASP.NET AJAX  ModalPopup.
It pointed me to jqModal – looks what I need.
You can pass the URL (e.g. $.jqm({ajax:’remote/dialog.html’}) or extract it from an attribute of the triggering element. For instance, $(.jqm({ajax:’@href’}) would grab contents from bar.html if the triggering element was <a href=”foo/bar.html”>
In particular see example 3b example-alert.
Standalone sample code of usung jqModal posted here. Other examples:
 Popup Master-Detail using GridView, DetailsView and JQuery with jqModal
Regardless of JavaScript client solution for cross-domain calls it’s required to use something like AJAX Proxy – continuously deliver data from across domains
My collegue found jqModel too complicated to setup and prefer DHTML Modal window
Other links that I read/considered:
jQuery plug-in Simple Modal.–iframe is depricated

Windows Workflow: Concatenate all parents QualifiedNames- instead of call stack

MSDN Debugging Workflows  tells that

The entries in the Call Stack window are a depth-first search of executing activities. You can double-click an entry to put focus on the selected activity.-It doesn’t work for me.

 The text on stack trace is not meaningful, when activities are described.

 > codeRaiseEvent_ExecuteCode(object sender = {codeRaiseEvent_CAGPNRIterate [System.Workflow.Activities.CodeActivity]}, System.EventArgs e = {System.EventArgs}) Line 671 C#
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.Activity.RaiseEvent(System.Workflow.ComponentModel.DependencyProperty dependencyEvent, object sender = {codeRaiseEvent_CAGPNRIterate [System.Workflow.Activities.CodeActivity]}, System.EventArgs e = {System.EventArgs}) + 0xb0 bytes 
  System.Workflow.Activities.dll!System.Workflow.Activities.CodeActivity.Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x35 bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutor<System.__Canon>.Execute(System.__Canon activity, System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x2b bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutor<System.__Canon>.Execute(System.Workflow.ComponentModel.Activity activity, System.Workflow.ComponentModel.ActivityExecutionContext executionContext) + 0x32 bytes 
  System.Workflow.ComponentModel.dll!System.Workflow.ComponentModel.ActivityExecutorOperation.Run(System.Workflow.ComponentModel.IWorkflowCoreRuntime workflowCoreRuntime) + 0xbe bytes 

I’ve created a function, that can be called to output trace in case of exception”

/// <summary>/// Concatenate all parents QualifiedNames
/// </summary> 
/// <param name=”activity”></param> 
public static string FullQualifiedName(this Activity activity)
Activity act=activity;
List<string> list = new List<string>();
while (act != null)
return CollectionsHelper.ToString<string>(list, “.”,“”);



Unrelated note that  to debug the workflow using F5 you MUST set the workflow DLL project as the Visual Studio solution startup project.


Code reviews and coding recommendations

We don’t have code reviews, but sometimes I have to tell the team quite obvious coding recommendations.

There are a few examples:

1. We should do the check if array element is available before access it:

 E.g. BAD:
            string departureCity = Flight[0].StartPoint;

GOOD:      if (Flight.Rows.Count <= 0)
                WarningMessageEvent.Raise(“Flight.Rows.Count <= 0″);
            string departureCity = Flight[0].StartPoint;

2. Keep separate functionality in small functions, rather than add morre code to existing functions, that makes them too big.

It is easier to read, test, maintain and investigate errors.

You can use VS Refactor –Extract Method to make functions smaller.

Also highly recommend to install RefactorAsp from http://www.devexpress.com/Products/Visual_Studio_Add-in/RefactorASP/index.xml.

See “Common Refactors” section here about

  • Extract method
  • Replace Method with Method Object
  • Decompose Conditional
  • List of Refactors can be viewed here(or original here).

    3. Do not “eat” exceptions 

    Even if you don’t want to report errors in production, Debug.Assert them in development environment to understand, why they happen and avoid them.
    E.g. BAD:
                    //we ignore any errors
                catch(Exception exc)
                    //we ignore any errors in production 
                    Debug.Assert(false, “Investigate why “ + exc.ToString());
    4. Use enums, do not hardcode magic values
    Use Enum (C#) instead of magic numbers 
    and (more general) C# Coding Style Guide .
    Aside note: By some reason this particular post is not searchable by Google. I have no idea why it is different from other posts.

    Logging application block-how configure different listeners for different level of message.

    and AvanadeSupport gave me the answer to use  “Filter” property of the tracelistener.
    MSDN Source Schema for the Logging Application Block   documents listeners Child Element (loggingConfiguration)/add Child Element

    Now I am able to make configuration like the following

    <loggingConfiguration name=”Logging Application Block” tracingEnabled=”true”>
          <add switchValue=”All” name=”MyApp”>
                     <add name=”EventLog Listener” />
                    <add name=”EMailErrors TraceListener” />
    add name=EMailErrors TraceListener     filter=”Error”
    type=Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.EmailTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null” 
    subjectLineStarter=test end
    subjectLineEnder=test start
    =Simple Text Formatter
    listenerDataType=Microsoft.Practices.EnterpriseLibrary.Logging.Configuration. EmailTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null
    I found for Mail listerners that despite of SourceLevels Enumeration  documentation, specified values do not include more serious events, e.g.  filter=”Warningswill apply for Warnings ONLY, not including Critical, Error, and Warning events.
    You have to explicitely declare and assign separate listerners for Error Warning or Information .
    Do NOT confuse listeners/add filter property (local for a listener) with  logFilters section(global for the LAB).


    Error: “Autogrow of file in database was timed out”

    We’ve had an error
    Autogrow of file ‘MyDatabase_dat’ in database ‘MyDatabase’ was cancelled by user or timed out after 30078 milliseconds. Use ALTER DATABASE to set a smaller FILEGROWTH value for this file or to explicitly set a new file size.

    I was able to fix the issue  using:
    MODIFY FILE ( NAME = MyDatabase_dat, size=5000MB)

    We should follow the best practices from MSDN article “Considerations for the “autogrow” and “autoshrink” settings in SQL Server”   

    In particular, use alerts or monitoring programs to monitor file sizes and grow files proactively. To reduce the possibility of running out of space, you can monitor the Performance Monitor counter SQL Server: Databases Object :Data File(s) Size (KB) and set up an alert for when the database reaches a certain size.

    MSDN Article PRB: A Timeout Occurs When a Database Is Automatically Expanding    has a few issues: Is it applicable for SQL 2005and 2008? If not,what are corresponding articles?It’s not clear, that “Expand the database manually.” is the recommended method.There are no examples of the ALTER DATABASE statement.
    Update: to investigate why the DB has too much space, see my post Stored procedure to find the biggest tables in the database

    Developers should avoid smart-quotes in Word

    We had a Word document, describing steps, based on MSDN instructions Use the Windows Workflow Tracking Service
    I desided to create batch file createWorkflowTrackingDB.bat to create Database:

    @echo Change name of Database server if required
    @echo press control-Z to stop batch
    sqlcmd -S localhost -E -Q “create database WorkflowTracking”
    cd “C:WINDOWSMicrosoft.NETFrameworkv3.0Windows Workflow FoundationSQLEN”
    sqlcmd -S localhost -E -d WorkflowTracking -i Tracking_Schema.sql
    sqlcmd -S localhost -E -d WorkflowTracking -i Tracking_Logic.sql
    @echo Ensure that application account has tracking_reader and tracking_writer roles

    But it was failing on the line
         sqlcmd -S localhost -E -Q “create database WorkflowTracking”.
    It took me a while to recognize, that MS Word replaced double-quotes with smart-quotes , and sqlcmd didn’t like it.

    Specify Expect100Continue=false in Web Service client.

    The Web Service Provider that we are using recommends NOT send Expect100Continue header.
    The specifying static value
    is not good, because some other providers may prefer to use the header.
    In the haacked’s “HttpWebRequest and the Expect: 100-continue Header Problem” post   comment of Mirronelli Jun 02, 2005 6:22 AM  suggest to specify webRequest.ServicePoint.Expect100Continue = false; for  each webRequest.

     If I am using web service(derived from SoapHttpClientProtocol) I can use ServicePointManager Class FindServicePoint method. 

    Uri uri=new Uri(xws.Url);
    ServicePoint servicePoint = ServicePointManager.FindServicePoint(uri);
    // Debug.Assert(servicePoint.Expect100Continue == false, “Investigate why not?.”);
    if (servicePoint.Expect100Continue == true)
    { //should happen only once for each URL
       servicePoint.Expect100Continue =


    SSIS import from Excel to SQL table doesn’t like empty lines

    I had a task yo import data from Excel spreadsheet to SQL Server table.
    Last time I tried to use SQL Server Management Studio import option, but it gave me some not clear errors, that I didn’t understand.
    So I’ve created SSIS project in VS and was able to narrow down the errors and import  the data.
    This time for similar spreadsheet I had some errors again. The output contained the warnings about length of the string column, that usually can be ignored, e.g.:
    Warning: 0x802092A7 at First Task, Destination – CompanyCountries [20]: Truncation may occur due to inserting data from data flow column “CountryCode” with a length of 255 to database column “CountryCode” with a length of 50.
    Ideally they should be shown only when the data string actually truncated.
    After a lot of information traces the errors similar the following were shown:

    Error: 0xC0202009 at First Task, Destination 2 – SIPPs [144]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.

    An OLE DB record is available. Source: “Microsoft SQL Native Client” Hresult: 0x80004005 Description: “Unspecified error”.

    Error: 0xC020901C at First Task, Destination 2 – SIPPs [144]: There was an error with input column “HireCompanyCode” (174) on input “Destination Input” (157). The column status returned was: “The value violated the integrity constraints for the column.”.

    Error: 0xC0209029 at First Task, Destination 2 – SIPPs [144]: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The “input “Destination Input” (157)” failed because error code 0xC020907D occurred, and the error row disposition on “input “Destination Input” (157)” specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

    Error: 0xC0047022 at First Task, DTS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component “Destination 2 – SIPPs” (144) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.

    Error: 0xC0047021 at First Task, DTS.Pipeline: SSIS Error Code DTS_E_THREADFAILED. Thread “WorkThread0” has exited with error code 0xC0209029. There may be error messages posted before this with more information on why the thread has exited.

    Task failed: First Task

    SSIS package “ExcelImport.dtsx” finished: Failure.

    I wasn’t able to find what [144] and (157) mean- I thought, that it’s lines in  the data input, but I didn’t find issues with particular rows.
    I had to remove all constraints and “not null” restrictions from the target SQL table before the import was successful.
    When I analyzed imorted data, I understood, that Excel had empty rows at the end, that were tried to import as null values.
    I’ve deleted null records and used sp_generate_inserts to create SQL script for production.
    By the way, when I included SSIS solution to TFS source control, the file Integration Services Project1.database was included. Previously I renamed the solution and project to the meaningful name, but this file wasn’t renamed. Do I need it at all? Can I rename it?

    “Edit and continue” not working in functions with LINQ

    I’ve started to use LINQ and feel that query expression are very powerfull.
    Unfortunately , when in debugger I’ve tried to  Edit and continue, it gave me an error
    Modifying a ‘method’ which contains a query expression will prevent the debug session from continuing while Edit and Continue is enabled. 
    The post Orcas – Edit and continued not working when linq used – MSDN Forums explains that “it is a limitation of the environment in which Edit and Continue operates”.
    I’ve submitted suggession to MS – please vote to push MS to improve  E&C support.
    Sometimes I feel, that E&C in VB6 was better.
    As a workaround I will try not to keep LINQ queries inside big function, but refactor them into small functions. Unfortunately it makes Language-INtegrated Queries not so-good in integration with language.
    By the way I am using refactoring from VS and Refactor! for ASP.NET , and extract function works better from VS; Refactor! not always correctly declares parameters.

    Function to Convert ASP.NET bool to JavaScript bool.

    I was generating some JavaScript in the server code and found that bool.ToString() doesn’t create string that JavaScript expects as boolean- .Net uses first letter as capital True/False. Then I found in my own class, that I’ve wrote helper function a long time ago:

    public static string JSToString(bool bValue)


                      return bValue.ToString().ToLower();