Saturday, June 25, 2011

How to: perform page break by printing ASP.NET Web forms

Once we created an ASP.NET Web Application having web forms the next request was to organize carbon copy of these forms: do print them and support page breaks.

The solution is:

  • declare dedicated div style class for separate print pages
  • add page-break-after: always; property to this class
  • enclose the print pages in separate div elements and set their style to the class declared above

Example:

the ASP.net Form:

<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="WebForm.aspx.cs"Inherits="WebForm"%>
<!DOCTYPEhtml PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
htmlxmlns
="http://www.w3.org/1999/xhtml">
<
headrunat
="server">
    <
styletype="text/css"media
="screen">
      
.formLabel
      
{
            min-width: 100px;
            color: Blue;
        }
       
.formTextBox
      
{
            width: 200px;
        }
    </style
>
    <
styletype="text/css"media
="print">
      
.formLabel
      
{
            min-width: 100px;
            color: Black;
        }
       
.formPage
      
{
            page-break-after: always;
        }
       
.formTextBox
      
{
            width: 200px;
        }
    </style
>
    <
title>Department Form</title
>
</
head
>
<
body
>
    <
formid="form1"runat
="server">
    <
div
>
        <
divclass
="formPage">
            <
asp:LabelID="LabelName"runat="server"Text="Name:"CssClass="formLabel"Width="100px"></asp:Label
>
            <
asp:TextBox ID="TextBoxName"runat="server"CssClass="formTextBox"></asp:TextBox
>
            <
br
/>
            <
asp:LabelID="LabelPhone"runat="server"Text="Phone:"CssClass="formLabel"Width="100px"></asp:Label
>
            <
asp:TextBox ID="TextBoxPhone"runat="server"CssClass="formTextBox"></asp:TextBox
>
            <
br
/>
        </
div
>
        <
divclass
="formPage">
            <
asp:LabelID="LabelAddress"runat="server"Text="Address:"CssClass
="formLabel"
              
Width="100px"></asp:Label
>
            <
asp:TextBox ID="TextBoxAddress"runat="server"CssClass="formTextBox"></asp:TextBox
>
            <
br
/>
            <
asp:LabelID="LabelRegPlate"runat="server"Text="Reg. Plate:"CssClass
="formLabel"
              
Width="100px"></asp:Label
>
            <
asp:TextBox ID="TextBoxRegPlate"runat="server"CssClass="formTextBox"></asp:TextBox
>
            <
br
/>
        </
div
>
    </
div
>
    </
form
>
</
body
>
</
html
>

The form in browser:
image

The form in print view:

imageimage

Enjoy!

Wednesday, June 22, 2011

Troubleshooting Firefox 5 and delicious bookmarks

Firefox 5 is here, and the problem described here appears again.

Use the same “cure”: change “4.*” to “5.*” and enjoy!

Wednesday, June 15, 2011

TFS 2008 Problem: Unable to connect to the Windows SharePoint Services

Assume, you plan to create a new TFS project using TFS 2008. Everything goes well up to the last step - then an error dialog appears saying “Unable to connect to the Windows SharePoint Services at <URI>”:

image

The reason is, the TFS instance cannot create the Sharepoint Portal for the project. More information is to find in the error log file on the TFS server.

Most popular problem are changed connection properties to Sharepoint instance (for example, port number). In this case the log file contains message, that the server rejects the connection on used URI.
(We discounter this error due to uncoordinated change in Sharepoint configuration, where the port number was altered in mistake).

OK, two things to take away.

1. Show the current TFS settings.

Log-in to TFS server, got to the TFS program files folder, the to the “Tools” subfolder – here you find the TfsAdminUtil: administration utility for TFS.

Start it using following command line:

TfsAdminUtil configureconnections

You see all the important current settings for local TFS instance:

image

2. Change required setting

For this task TfsAdminUtil offers set of keys/options:

x10sctmp0

For example, use /SharepointAdminUri: to change Sharepoint Administration URI:

TfsAdminUtil configureconnections /SharepointAdminUri:http://myserver:myport/_vti_adm/admin.asmx

Think about full path to the administration service file (.asmx), not just admin site URL!

image

Use TfsAdminUtil to view changed settings as shown above, restart TFS server and enjoy!

Tuesday, May 31, 2011

Online virus check: http://www.virustotal.com

Online tool to check any file or web site for viruses and malware:

http://www.virustotal.com

x10sctmp

Enjoy!

Friday, May 20, 2011

How Internet Explorer versions handle bad-formed XML files

Following the change from Beta to RTM Version of IE 9 in display of XML files feature we continue to work with IE using it to display XML files in certain situations.
Well, after the IE9 RC version turned back to “traditional” XML data display format, the problem seems to be solved.
But there’s a significant change in this functionality of Internet Explorer 9 and Internet Explorer CTP 10 in XML data display policy: this time it is about the bad-formed XML files.
Assume a well-formed XML file:
<root>
<element name="3" />
sample text
<element name="1" />
<element name="2" />
</root>
 
This file is displayed properly in IE8:
 
x10sctmp2
in IE9:
 
x10sctmp0
 
and in IE10:
x10sctmp1
 
Then we try following bad-formed XML data:
<root>
sample text
<element name="1" />
<element name="2" >
<element name="3" />
</root>

(the element [element name=”2”] has no closing tag)

This file is displayed in IE8 as expected:

x10sctmp3

The IE9 displays the same data as follows:

x10sctmp4

Neither the error notification nor any explanation are presented to the user. Via the option “View Source” you can see the source XML data, but again – no error information exists:

x10sctmp5

The same for HTML view in Developer Tools Window (activated by F12):

x10sctmp6

And only Console view:

x10sctmp7

and Script view provide us with error information:

x10sctmp8

Same behavior shows also the IE10 CTP:

x10sctmp9 x10sctmp10

Using “Force IE7” … “Force IE9” mode doesn’t affect this behavior.

The FireFox 4 displays the same well-formed XML:
x10sctmp11

and bad-formed as expected from previous FF versions:
x10sctmp12

This difference in handling of bad-formed XML data may be essential for a custom application using web browser to display XML data. Just keep it in mind…

Wednesday, May 18, 2011

Microsoft Office 2010 Service Pack 1 is here

As announced on the TechEd 2011, “Service Pack 1 [for Microsoft Office 2011 – mb]is on track for release at the end of June.”.

The most important highlights:

  • Outlook fixes an issue where “Snooze Time” would not reset between appointments.
  • The default behavior for PowerPoint "Use Presenter View" option changed to display the slide show on the secondary monitor.
  • Integrated community content in the Access Application Part Gallery.
  • Better alignment between Project Server and SharePoint Server browser support.
  • Improved backup / restore functionality for SharePoint Server
  • The Word Web Application extends printing support to “Edit Mode.”
  • Project Professional now synchronizes scheduled tasks with SharePoint task lists.
  • Internet Explorer 9 “Native” support for Office Web Applications and SharePoint
  • Office Web Applications Support for Chrome
  • Inserting Charts into Excel Workbooks using Excel Web Application
  • Support for searching PPSX files in Search Server
  • Visio Fixes scaling issues and arrowhead rendering errors with SVG export
  • Proofing Tools improve spelling suggestions in Canadian English, French, Swedish and European Portuguese.
  • Outlook Web Application Attachment Preview (with Exchange Online only)
  • Office client suites using “Add Remove Programs” Control Panel

Lucky me, starting from now I can display the PP presentation on the secondary monitor (usually projector), having my primary display on the notebook running web browser and mail client without risk to expose sensible data to the students.

I was really waiting for this feature…

Monday, May 16, 2011

Federal Communications Commission’s Website unavailable

Days after announcing PLAN (Personal Localized Alerting Network) stays the Federal Communications Commission’s Website unavailable – occasion?

x10sctmp

Friday, April 15, 2011

Internet Explorer 10 Preview: download the testdrive

IE10 is available for download: http://ie.microsoft.com/testdrive/

Here is it:
image

Lot of Demos, Developer Information etc. User Guide is here: http://ie.microsoft.com/testdrive/Info/UserGuide/

Developer Tools are already included and can be launched as usual: F12. As expected, browser compatibility mode 10 has been added:

image

Useful: main menu –> Report Issue –> Run IE Diagnostics. Displays a lot of info about current system and provides 2 protocol options - network and process activity:

image

The results are written in a cab file.

“Microsoft continues HTML5 commitment and leadership with the first platform preview of Internet Explorer 10.” (from here)

IE10 expected to be delivered also for tablets, in perspective probably also for Windows Phone devices.

While there is no support for Windows Vista and older, this preview version does install and run side-by-side with IE9 on the Win7 with all most recent updates and fixes – at least on my machine. The public updates are expected to be available every 12 weeks.

Download and enjoy the exploring of IE10!

Friday, April 08, 2011

Troubleshooting Firefox 4 and delicious bookmarks

If you used delicious bookmarks with FF 3.x and recently updated FF to the version 4.0, you’ll be negatively surprised, the delicious toolbar is not displayed anymore: the delicious bookmarks add-on isn’t yet officially compatible to FF 4.0.

The found solution (here in german: http://wordpress.kendaric.net/2011/03/17/delicious-plugin-im-firefox-4-nutzen/) described the steps to solve the problem:

  1. Start FF and navigate to “about:support
  2. Click “Open containing folder”
    image
  3. Navigate in the newly opened explorer window to subfolder “extensions\{2fa4ed95-0317-4c6a-a74c-5f3e3912c1f9}”:
    image
  4. Open install.rdf and find the line with “em:maxVersion”
    image
  5. Change the value to “4.0”
    image
  6. Save the file and restart FF.
  7. Enjoy!Smile

Wednesday, April 06, 2011

Display last “build completed” time in Visual Studio 2008/2010

The build process in VS08/10 doesn’t display by default the timestamp of the “build completed”:

image

We use following post-build event setting:

[your code if necessary]
echo build completed
time /t


image


This generates a timestamp in output window displaying the time when the build was completed:


image


So you can see if you are dealing with most recent build.


Enjoy!

Friday, March 25, 2011

Microsoft SharePoint Foundation 2010 prerequisites

Before you start to install Microsoft SharePoint Foundation 2010, ensure you installed all the prerequisites. You can check them directly from the setup package.

Otherwise download them from Microsoft download center or other web resources - like this one:

http://forum.it-share.ro/Forum/Sharepoint%202010%20Prerequisite%20Download/Forms/AllItems.aspx?View={F50B49F5-3617-43BB-9FB4-3C4F51B805C7}

Here is as for today only the reporting services add-in missing – you will find it here:

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3bebf9d-d86d-48cd-94e2-0639a846be80

Enjoy!

Thursday, March 03, 2011

ASP.NET & AJAX: “Object required” Script error while using ModalPopupExtender

Loading an ASP.NET Webpage containing ModalPopupExtender you may encounter following error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
Timestamp: Thu, 3 Mar 2011 07:21:58 UTC


Message: Object required
Line: 106
Char: 13
Code: 0
URI:
http://localhost:49461/ScriptResource.axd?d=dVTmaeP-mJEQBF1x5WPACI57lI3BdxWWqqcjOSvk5IFYlzy3XmoJ3-mETMUX_E93dUXCirqabEt7Y5F8nk9OJF0v1sSq6MFJL4n1ystjZ74KXzsw7JAw7fRseSEZ165rrnTm4dOfgdUE7UZpQUpfBqdlctB5nzYxeqQR46Jg_TR_hyK50&t=ffffffffa4fab0f1

image

Start debugger, and you will learn more:

image

this._popupElement = $get(this._PopupControlID);
if (this._DropShadow) {
this._foregroundElement = document.createElement('div');
this._foregroundElement.id = this.get_id() + '_foregroundElement';
this._popupElement.parentNode.appendChild(this._foregroundElement);
this._foregroundElement.appendChild(this._popupElement);
}
else {
this._foregroundElement = this._popupElement;
}


The cause of this error is most likely the Panel used as TargetControl for ModulPopupExtender. Check if this Panel not set accidentally to



Visible="false"


In this case ASP.NET doesn’t render this panel at all, and the _PopupControlID property of the popup extender on the client side points to non existent object.


Check the Visible attribute of the popup panel, reset it to visible and enjoy!

Wednesday, March 02, 2011

Internet Explorer reports error: “The specified module could not be found”

Browsing (your customized?) ASP.NET application with IE7/8/9 you may encounter following error:

clip_image001

The error message says: “The specified module could not be found”. Most frequently you will encounter this error while displaying the pages containing Accordion AJAX control.

Surprisingly, other browsers like Firefox or Chrome do not cause this error and still display the Web application pages and all the controls correctly.

There are numerous methods to debug this error, we selected the local instance of Visual Studio:

clip_image001[4]

The error occurs exactly in getOpacity() function of a local JScript:

clip_image001[6]

getElementOpacity : function(element) {
if (!element) {
throw Error.argumentNull('element');}
var hasOpacity = false;var opacity;if (element.filters) {
var filters = element.filters;if (filters.length !== 0) {
var alphaFilter = filters['DXImageTransform.Microsoft.Alpha'];if (alphaFilter) {
opacity = alphaFilter.opacity / 100.0;hasOpacity = true;}
}
}

Quick watch on the filters says exactly the error we saw above:

clip_image001[8]

The Interface IHTMLFilterCollection is implemented in oleaut32.dll:

clip_image002

clip_image002[4]

clip_image002[6]

clip_image002[8]

There’s a Microsoft KB article describing a similar problem: http://support.microsoft.com/kb/281679/de.

According this article just try to re-register the oleat32.dll and actxprxy.dll:

clip_image002[10]

clip_image001[10]

clip_image001[12]

On some computers it helped.

On others we were obliged to re-run dxdiag: to detect any DirectX errors on the workstations. Some of them were cured just after installing of most recent DirectX graphics drivers

The rest of boxes displayed the same error: “DCIMAN32.DLL is missing”.

This is a symptom, some of latest software updates or new installations corrupted the system and removed the DCIMAN32.DLL from the %SYSTEM% folder. Short description was presented here: http://answers.microsoft.com/en-us/windows/forum/windows_7-system/dciman32dll/b38a81fa-89f2-4550-8749-89e91a6f0a40

But one more tasks of this library is to provide Internet Explorer with additional graphics related functions, that rely on the interfaces of this library and underlying modules. Fortunately, other browsers do not rely on this operating system dependent functionalities, so they can display the pages correctly.

What we’ve done was the fresh copy of DCIMAN32.DLL form an healthy reference system directly into %SYSTEM% folder of the victim machine – you do not event need to register this library with regsvr32 or reboot the computer.

It just worked after this – try to follow the steps and enjoy!

Thursday, February 24, 2011

ASP.NET: FindControl() returns null for an existing control while this control is still accessible via member variable

Building an AJAX enabled ASP.NET application we encountered the effect mentioned in the title of this article.

There is a TabContainer with a TabPanel containing a TextBox.

<cc1:TabPanel runat="server" ID="TabPanel1" TabIndex="0" HeaderText="Person">
<
ContentTemplate>
<asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox>
</
ContentTemplate>
</
cc1:TabPanel>


This TextBox is accessible via a member variable, which is automatically created by Visual Studio Designer:


this.TextBoxName.Text = "Enter name here...";


If you try to access the TextBox using FindControl() method of Page class, you will be alerted with following message:



image



The error message is: “Object reference not set to an instance of an object.”.



That means, the FindControl() method cannot find the control by specified ID an returns null.



Slightly surprised (the TextBox is still accessible via member variable) we looked towards Microsoft Knowledge Base and Forums and found following article: http://msdn.microsoft.com/en-us/library/y81z8326%28v=vs.90%29.aspx#Y2166



It says: “When a control is not inside a naming container, you can get a reference to it by using the control's ID. When a control is inside a naming container, you must call a method that searches the naming container for the control's ID. A control might also be inside a naming container that you do not have direct access to.



To access a control by its ID inside a naming container, you have to extend your Page by instance method FindControlRecursive() described in the referenced article as well:

… 
((TextBox)this.FindControlRecursive(this,"TextBoxName")).Text = "Enter name here..."
… 
private Control FindControlRecursive(Control rootControl, string controlID) 

if (rootControl.ID == controlID) return rootControl; 
    foreach (Control controlToSearch in rootControl.Controls) 
    {


    Control controlToReturn =


                FindControlRecursive(controlToSearch, controlID);


     if (controlToReturn != null) return controlToReturn;


    }


    return null
}



It works! Enjoy…

Wednesday, February 23, 2011

HOWTO: find descendant XElement in XDocument by its name recursively using LINQ with namespaces

If you want to use LINQ to locate XML nodes by their names and your XML contains namespace notations, be aware to specify namespaces looking for descendants.

XML Example:

<?xml version="1.0" encoding="utf-8"?>
<
MyDataStruct xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <
DataRoot xmlns="http://mydata.org/2011/1">
    <
Dispatch xmlns="http://mydata.org/2011/1">
      <
Target>
        <
Organisation>
          <
Comment></Comment>
          <
ID></ID>
        </
Organisation>
        <
System>
          <
ID>100</ID>
          <
Comment></Comment>
        </
System>
      </
Target>
      <
Source>
        <
Organisation>
          <
Comment></Comment>
          <
ID></ID>
        </
Organisation>
        <
System>
          <
ID>101</ID>
          <
Comment></Comment>
        </
System>
      </
Source>
    </
Dispatch>
  </
DataRoot>
</
MyDataStruct>

LINQ based recursive search operations:

XDocument xDoc = XDocument.Load(xmlFileName);

XElement xe1 = xDoc.Descendants("{http://mydata.org/2011/1}Target").First(); // locate first “Target” node
   XElement xe1 = xDoc.Descendants("{http://mydata.org/2011/1}Source").First()
                                  .Descendants("{http://mydata.org/2011/1}ID").First(); // locate “ID” subnode of“Source” node

UPDATE: seen also here -

http://stackoverflow.com/questions/566167/query-an-xdocument-for-elements-by-name-at-any-depth

Enjoy!

Friday, February 11, 2011

Internet Explorer 9 RC to download

Internet Explorer 9 Release Candidate can be downloaded at http://www.beautyOfTheWeb.com or at http://windows.microsoft.com/en-US/internet-explorer/downloads/ie.

OS supported are: Windows Vista/Windows 7/Windows Server 2008/Windows Server 2008 R2. There are already many languages available.

Finally the old known display mode for XML is back! (see my article: Internet Explorer 9 Beta does not display XML files in tree view ).

image

The site http://www.beautyOfTheWeb.com offers interesting information about new features and development tools for IE9.

Additionally there are advertised some featured sites tuned/created for IE9. One of my famous sites is BeatKeep: http://www.beatkeep.net/ - online music editor for (hobby) musicians.

Just download IE9 RC, navigate to BeatKeep and enjoy!