Make your web page more printer-friendly

Below there are a few links describing how to Make your web page more printer-friendly

Page dimensions : print :Maximum width = 560 pixels

 

CSS Media Types Create Print-Friendly Pages – Save print.css in the same directory as the file, include the <link rel=”stylesheet” type=”text/css” href=”print.cssmedia=”print” />

complete css guide – Printing

 CSS and Printing  describes Page Break  

<STYLE TYPE=”text/css”>

     P.breakhere {page-break-before: always}

</STYLE>

This then will be the activator for the page break:

 <P CLASS=”breakhere”>

 css guide – Media

MOM error- “BounceService: Service start of OnePoint failed. Error: 10”

Today our MOM 2000  stopped working. Looking on MOM Esrver local eventlog we found that every few minutes OnePoint  starts , than we have message BounceService: Service start of OnePoint failed. Error: 10” and it stops.

Attempt to start OnePoint manually didn’t succeeded.
I was able to find workaround based on info from article http://www.huntland.co.uk/Downloads/MOM/ServiceBounceAsync.html

To start OnePoint service I had to disable rule for “Agents Consolidators or Data Access Servers”
(full path is Microsoft Operations Manager/Rules/Processing Rules Groups/Microsoft Operations Manager/Agents Consolidators or Data Access Servers/Performance Processing Rules/OnePoint service handle count > 10,000 (handle leak) – Bounce Service)
and rule for “Consolidator”
(full path is Microsoft Operations Manager/Rules/Processing Rules Groups/Microsoft Operations Manager/Consolidator/
Threshold Process-Private Bytes-OnePointService Consolidator – Bounce Service)
 
We will need to enabled them later and see what happened.

Naming Guidelines: Names for embedded Enum and Property of the enum type

Property Naming Guidelines recommends to consider creating a property with the same name as its underlying type. For example, if you declare a property named Color, the type of the property should likewise be Color.
Enumeration Type Naming Guidelines recommends  do not use an Enum suffix on Enum type names.
 
I found this recommendation conflicting if I want to declare Enum within class and have a property of the type of this enum.
I’ve tried to create something like the following:.
 
public class Control
{
   public enum Color
  {
   // Insert code for Enum here.
  }


   public Color Color //confusing
   {
      get {// Insert code here.}
      set {// Insert code here.}

}

}

This doesnt’t work well, because compiler confused, do you refer to the Enum or Property. It probably will work if you will refer to enum with fully qualified namespace.
It also will work, if enum Color will be declared outside the class(as in
MSDN example), but I don’t want to do it, because my enum is logically belongs to my class.

The possible alternative is to ignore recommendation  do not use an Enum suffix

public class Control
{
   public enum ColorEnum // not recommended
  {
   // Insert code for Enum here.
  }


   public ColorEnum  Color 
   {
      get {// Insert code here.}
      set {// Insert code here.}

}

}

The best way is to use the name of the property derivative but different to enum.
If you have too many members in the class, consider to add an extra word as the suffix, not prefix- to help find the property in IntelliSence. For example,
ColorSelected will be easier to find, than SelectedColor

public class Control
{

   public enum Color
  {
   // Insert code for Enum here.
  }


   public Color ColorCurrent //or ColorSelected or ColorMyFavorite
   {
      get {// Insert code here.}
      set {// Insert code here.}

}

}

Is it possible to convert Workflow to Custom composite activity?

I am reading about Windows Workflow and have a question:

If I created a workflow with a few activities (While,If etc) and want to convert it to custom composite activity with ability to insert new activities inside blocks, how can I do it?
Analogy in ASP.NET is strightforward- just a few steps(see How to: Convert Web Forms Pages into ASP.NET User Controls ) .

Is something similar available for WF?

Related links how to write Custom activities:
Creating a Custom Composite Activity – Morgan Skinner’s  article on MSDN

MSDN documentation Concepts:  Creating Custom Composite Activities
How to Write a Custom Workflow Activity  ,How to Write a Designer Component for Custom Workflow Activity

A few links in OdeToCode blog: Windows Workflow Foundation and Domain Specific Languages

RadioButton with Image instead of text

I want to have RadioButton with Image instead of text, that clicking on image the check-box will be selected
 
In the thread it is shown Radio button (without any text) and image on it’s side.(but not inside radio-button)
<asp:RadioButton ID=”RadioButton2″ runat=”server” GroupName=”A1″
/><asp:image runat=”server” id=”Image2″ /><br />
 
Radiobuttonlist Image Setting thread  suggests to use code
RadioButtonList1.Items.Add(New ListItem(“<img src=””” + s + “””/>”, s))

It will be useful (TODO) to create derided from RadioButton control- RadioButtonWithImage, similar to what I’ve done previously : ASP.NET custom control HyperLinkWithImage and ASP.NET custom control CheckBoxWithImage

 
There is somehow related post and thread about creating custom control based on RadioButtonList.

New posts of source code about old Asp.net custom controls

I’ve found in my source code library a few custom ASP.NET controls that could be useful for someone.

ASP.NET custom control TextFileViewerControl

 

 

 

 

 

ASP.NET composite control FromToTextBoxes

 

 

 

 

 

ASP.NET custom control CheckBoxWithImage

 

 

 

 

 

My QueryStringHelper class.

 

 

 

 

 

ASP.NET custom control TextFileViewerControl

This control opens text file and shows it as plain text in ASP.NET page.
It optionaly can delete the file(if it was temporary) after the reading.

 The source code posted using CopySourceAsHtml

using System;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

using System.IO;

using FSHelperLib;

namespace FSWeb.CustomControls

{

    /// <summary>

    /// Summary description for TextFileViewerControl.

    /// </summary>

    [DefaultProperty(“Text”),

        ToolboxData(“<{0}:TextFileViewerControl runat=server></{0}:TextFileViewerControl>”)]

    public class TextFileViewerControl : System.Web.UI.WebControls.Panel

    {

    //    private string text;

 

        public TextFileViewerControl(): base()

        {m_deleteAfterReading=false;

        }

 

        [Bindable(true),

            Category(“Data”),

            DefaultValue(“”)]

            // Properties

        public string FilePath

        {

            get

            {

                return this.m_sFilePath;

            }

            set

            {

                this.m_sFilePath = value;

            }

        }

 

 

        // Fields

        private string m_sFilePath;

 

        /// <summary>

        /// Property DeleteAfterReading (bool)

        /// </summary>

        [Category(“Behaviour”),DefaultValue(false)]

        public bool DeleteAfterReading

        {

            get

            {

                return this.m_deleteAfterReading;

            }

            set

            {

                this.m_deleteAfterReading = value;

            }

        }

        private bool m_deleteAfterReading;

        /// <summary>

        /// Render this control to the output parameter specified.

        /// </summary>

        /// <param name=”output”> The HTML writer to write out to </param>

        protected override void Render(HtmlTextWriter output)

        {

            output.Write(RenderTextFile(FilePath));

        }

        public string RenderTextFile(string sFilePath)

        {

            string sRet=“”;   

//            try

            {

                // Create an instance of StreamReader to read from a file.

                // The using statement also closes the StreamReader.

                using (StreamReader sr = new StreamReader(sFilePath) )

                {

                    String line;

                    // Read and display lines from the file until the end of

                    // the file is reached.

                    while ((line = sr.ReadLine()) != null)

                    {

                        sRet+=line+  HtmlHelper.NewLine;

                    }

                }

                if(DeleteAfterReading==true)

                    File.Delete(sFilePath);

                return sRet;

            }

//            catch (Exception ex)

//            {

//                throw new FileLoadException(“The file could not be read:”,sFilePath,ex);

//            }

        }

 

    }

}