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 =