Archive

Archive for the ‘ASP.NET’ Category

How to push (insert) HTML to a UpdatePanel

It is often useful to insert HTML code in an ASP.net page from the code behind. This can be achieved using an update panel as demonstrated below:

UpdatePanel1.ContentTemplateContainer.Controls.Add(new LiteralControl("This is a text from code behind."));
Advertisements
Categories: ASP.NET

Font size problem in exporting Crystal Report to PDF using ASP.Net

March 25, 2010 1 comment

http://forums.asp.net/t/1212106.aspx

I noticed a font size problem in exporting Crystal Report using Crystal 11.5 and ASP.Net 3.5.  In this case I needed to export a Crystal Report contains some barcodes.  The barcodes in the exported PDF had a very small font size. Searching web, I found that this issue can be fixed using to registry keys:

SAP Knowledge Base Article:

To resolve the behavior

  1. Set the resolution of the default printer of the local computer experiencing the issue to 1200 DPI. Most printers have a default setting of 600 DPI.
  2. Create two registry keys to prevent the crxf_pdf.dll from decreasing in font size.
  3. Click StartRun. Type “regedit”. The Registry Editor appears.
  4. Create the following keys for Crystal Reports XI with the defined values:HKEY_CURRENT_USER\Software\Business Objects\Suite 11.0\Crystal Reports\Export\PDF\ForceLargerFonts
    Type: DWORD
    Recognized Values: 0,1
    Default Value: 1
    Creation Method: manual

    HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.0\Crystal Reports\Export\PDF\ForceLargerFonts
    Type: DWORD
    Recognized Values: 0,1
    Default Value: 1
    Creation Method: manual

  5. Set both registry key values to 1 to turn them on.
  6. Create the following keys for Crystal Reports XI Release 2 with the defined values:HKEY_CURRENT_USER\Software\Business Objects\Suite 11.5\Crystal Reports\Export\PDF\ForceLargerFonts
    Type: DWORD
    Recognized Values: 0,1
    Default Value: 1
    Creation Method: manual

    HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports\Export\PDF\ForceLargerFonts
    Type: DWORD
    Recognized Values: 0,1
    Default Value: 1
    Creation Method: manual

  7. Set both registry key values to 1 to turn them on.
  8. Restart the Crystal Reports Page, Job and Cache Servers

and for the Unix server:

UNIX, an X server client such as x-win32 must be installed. Add the keys as follows:

  1. Launch the X server client (alternatively use xming on the client machine and export the display to the client machine.
  2. Login as business Objects user
  3. Go to the business objects installation folder: cd  <bobje install>/bobje/setup/
  4. Sorce env.sh (for example: . ./env.sh).
  5. Type regedit
  6. Create the registry keys as detailed below.
    1. Create the following keys for Crystal Reports XI Release 2 with the defined values:
    2. Create a new key under ‘HKEY_CURRENT_USER\Software\Business Objects\Suite 11.5\Crystal Reports’ called ‘Export’
    3. Create a new key under ‘HKEY_CURRENT_USER\Software\Business Objects\Suite 11.5\Crystal Reports\Export’ called ‘PDF’
    4. Create a new Dword value called ‘ForceLargerFonts’ under ‘HKEY_CURRENT_USER\Software\Business Objects\Suite 11.5\Crystal Reports\Export\PDF’
    5. Set the value to 1 (just double click on the name you just created)
    6. Create a new key under ‘HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports’ called ‘Export’
    7. Create a new key under ‘HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports\Export’ called ‘PDF’
    8. Create a new Dword value called ‘ForceLargerFonts’ under ‘HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.5\Crystal Reports\Export’
    9. Set the value to 1 (just double click on the name you just created).
  7. Restart the Crystal Reports Page, Job and Cache Servers.

I followed the provided instruction in SAP knowledge base but it did not work for me. I set the registry at HKEY_LOCAL_MACHINE which I expected to affect IIS, and then I set the HKEY_CURRENT_USER registry (which to me is not relevant as IIS uses different profile), then restarted the web server. The result was still barcode printing in small font.

Further search on the web I found a new solution in SAP community forum: https://forums.sdn.sap.com/thread.jspa?threadID=1161804

1. Press Ctrl-Alt-Del on your keyboard, then click the Task Manager button. Click the Processes tab. The security account is listed beside your process name (for IIS 5 the process name is aspnet_wp.exe and for IIS 6 it is w3wp.exe).

2. Open the registry editor. On the Start menu, click Run then type “regedit” and click OK.

3. Navigate to the following registry sub key:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList

There will be a number of keys here that start with “S-1-5”. Inspect each one and look for your security account name in the ProfileImagePath entry. Take note of the key (folder) you are on when you find your process.

4. Go to the following registry sub key:

HKEY_USERS[your security profile]\Software\Crystal Decisions\10.2\Crystal Reports\Export\Pdf

5. Right-click the sub key and click New > DWORD Value. Name the DWORD value “ForceLargerFonts” and set it to the value of 1.

6. Restart IIS, and try the application again.

My experience:

The IIS running on a XP machine where the Process Name (Image Name) equals to aspnet_wp.exe and the User Name equals to  ASPNET.   Looked at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and found that  S-1-5-21-1085031214-562591055-839522115-1004 has the value of

Value Name: ProfileImagePath

Value data: %SystemDrive%\Documents and Settings\TESTXP17908\ASPNET

Next step: I added ForceLargerFonts value to HKEY_USERS\S-1-5-21-1085031214-562591055-839522115-1004\Software\Business Objects\Suite 11.5\Crystal Reports\Export\PDF.

Restarted IIS

Result: Problem solved :)

Other web links and references:

White space (blank line) top of the ASP.Net Menu in IE8

September 2, 2009 Leave a comment

Following my previous post about applying a hot fox for ASP.Net menu control, I discovered that the z-index is not the only issue to fix. ASP.Net control when it gets rendered in IE8 shows a gap on top of it like a blank line or a white space.  Sakya found out and explains on his blog that it is the result of SkipLinkText which is not rendered in IE7 but IE8 render it.

The following code snippet shows how to set SkipLinkText to blank.

<asp :Menu ID="Menu1"  runat="server"
     DataSourceID="SiteMapDataSource1"
     SkipLinkText="">
</asp>

For more information refer to http://blogs.iis.net/sakyad/archive/2009/04/11/asp-net-menu-control-getting-padded-with-white-space-on-ie8.aspx.

Categories: ASP.NET Tags: , ,

Align a table in the middle of an HTML | XHTML page

August 26, 2009 Leave a comment

In the past it was common to align a table in the middle of a HTML page using the following code:

<div align="center">
<table>
<tr>
<td>
        Test String</td>
</tr>
</table>
</div>

However, this is no longer working as in the new XHTML standards “align” is not a valid attribute of

. So a better solution is to set the margin of the table to “auto”. You can delete the

as it is no longer needed for this purpose:

  <table style="margin: auto;">
    <tr>
      <td>
        Test String
      </td>
    </tr> 
  </table> 
Categories: ASP.NET Tags: , , ,

ASP.Net menu does not work in IE8

August 24, 2009 1 comment

The first problem which I found with the ASP.Net applications runing on IE8 was the dynamic menu. It does not invoke correctly as the default value for Z-Index is no longer valid for IE8. The problem and the work around it, is explained in

http://support.microsoft.com/kb/962351

In addition, the following list of issues and hotfixes related to ASP.Net 2 are important to review:

961847 FIX: Error message when you view a page in design mode after you recompile a .NET Framework 3.5 Service Pack 1-based project: “Error creating control – ‘ControlInstanceName [text]’ could not be set on property ‘PropertyName'”

961864 FIX: Web clients may have several problems when you access an ASP.NET 2.0 AJAX-enabled Web site

961884 FIX: You experience very slow performance on an initial request to an ASP.NET Web site after you change the App_Code folder, the bin folder, or the Global.asax file

962351 FIX: The pop-out menus are not displayed when you use Internet Explorer 8.0 in Standards mode to view an ASP.NET Web page that has dynamic menus

961902 FIX: Error message when you compile an ASP.NET project that contains many application resource files: “A first chance exception of type ‘System.ArgumentException’ occurred in mscorlib.dll”

968392 Error message and the hyperlink control is not rendered if the ImageUrl property is set in Visual Studio 2005 or Visual Studio 2008 after you install .NET Framework 2.0 Service Pack 2 or .NET Framework 3.5 Service Pack 1:”Object reference not set to an instance of an object”

Reference: http://support.microsoft.com/?id=969612

Other blog posts related to this issue:

Repair .Net 2: missing Netfx20a_x86.msi

June 30, 2009 1 comment

In my previous post I mentioned about a repair process for .Net 2 in order to host WCF in IIS . However, after following Microsoft instruction on repair process you may face an annoying issue where Windows installer can not find Netfx20a_x86.msi.

Netfx20a_x86.msi is a component of .Net 3.5 and it will get extracted to a folder such as “C:\5409af1fab5096fc4d07947959\wcu\dotNetFramework\dotNetFX20” as part of the install process. I tried to extract the file from the folder and use it for repairing .Net 2.0 but it did not work. After providing the msi file it will look for the setup.exe.

Solution: Ignore repairing .Net 2 and repair .Net 3 (or 3.5 if installed). In my case repairing .Net 3.5 fixed the issue in IIS.