Home Page





Web Application Development Blocks

Author: Alen Siljak

Display Data Authentication/Authorization Reports
Configuration Internationalization Deployment External Controls
Tips'n'Tricks Excel Export    



{0:c} for currency or {0:f2} for fixed


Use CSS for Buttons, Textboxes and other stuff.

Using <iframe>

In FrontPage, select <iframe> element by clicking the top border of the frame. Go to Format -> Properties. Set the frame properties there. Border can be visible or invisible.


WebUtil library now contains an implementation of a MessageBox for asp.net. MessageBox class has a shared method that is called to display a message.

Also check MessageBox.dll, which displays different kind of messages (alert, prompt, etc.) but has a roundtrip because it returns a selected value. This is used in case javascript prompt was used. The negative side is that even for a simple alert it has a postback.



Data/Business layer: doodads framework. Two-way data binding. The easiest data binding, so far, is to load the data in a business object, show it on page (txt_something.text = my_object.something) and on Save to the opposite (my_object.something = txt_something.text).



Read here




C1 & Infragistics



Microsoft Configuration Application Block?



Multilanguage options. SQL based translator.

Translated pages should be cached once translated, for performance. Because a solution is versatile, it can be configured which database to use, whether by setting the connection string, or by using a database name property.

[Database: Translation]


ID (255), MessageGroup

Message_ID (255), Language (2), Translation (ntext)

[MessageGroup (Group_ID, Message_ID)]

[Language (Code, Name)]

All text messages are stored in SQL database. One language is default (English, for example). Message in English is the key for the data row. A configuration setting should be used to indicate whether to translate the page. For example, if the page should be displayed in default language, it should not be translated. Also, if a message in default language is longer than 255 characters it should use Translation (ntext) field instead of the key field.

Messages belong to groups, for faster loading. For example, a name of the containing page is the name of the group so that all messages belonging to that page can be loaded in one database connection. Groups can also be displayed dynamically so that they are stored in MessageGroup field inside Messages table.

Table.Rows.Find() method can be used to find individual messages, once a datatable is retrieved. In case a message doesn't exist in the result set, it needs to be created.

Inserting a new message also assigns the group. In case a message belongs to multiple groups, Translator checks whether the message already exists and only assigns it to the other group.

Translate() translates only a line of text. This method is also used from translate_page, so it should check whether the translations table was already filled earlier.

Languages are created dynamically during interpretation process. The list of languages can be displayed by selecting distinct language fields. Language code has to be the same as the ISO standard code because current culture name is used sometimes.

There is a special case when a text should not be translated.

Messages are interpreted in a separate form. The translation form is included in the application.

ISO 639 language codes at Library of Congress, and local copy.

Declarative Globalization example.

Resource files (.resx, .resource) can be embedded into assemblies. Adding resource file to the project will compile that resource file into the assembly. Resource Manager is used to retrieve the resources from the resource files. To read a resource from the same assembly, use:

Dim rm As New ResourceManager(o_assembly.GetName.Name + ".localized_strings", o_assembly)

The name of the resource file consists of the name of the assembly plus the name of the file. See above example.

Also, for simple cases, text can be stored on page. File -> Save As needs to be used to save the file with encoding. UTF-8 with signature usually works.



Infragistics deployment document. In brief: add config section to web.config with custom path to images and scripts. Copy all .dlls to bin folder of the application. The code should be directly after <configuration> tag.

<!-- * Infragistics custom location * -->
    <section name="infragistics.web" 
    type="System.Configuration.SingleTagSectionHandler,System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

<!-- <infragistics.web imageDirectory="~/images" javaScriptDirectory="~/scripts"/> -->
    javaScriptDirectory="/ig_common/20043/scripts" />
<!-- ** -->


External Controls


Tips & Tricks

Disable Back

Disabling the option to go back in web browser.

Response.CacheControl = "no-cache"
Response.AddHeader("Pragma", "no-cache")
Response.Expires = -1


View in Browser - Internet Explorer instead of internal browser

Right-click, Browse With..., select Internet Explorer, Set As Default.


Word File Manipulation in ASP.Net

This archive contains the pages that demonstrate how to send Microsoft Word 2003 file (WordML) to the client browser. The file is created in word and stored on server. Asp.Net page loads the xml file, replaces some tags with needed content and sends the file to the client.

References: Transform XML to RTF for Word l MS Word Document from ASP.NET l Word 2003 WordML l Creating Word Documents with XSLT


Excel Export

Data can be exported from a data grid into an Excel spreadsheet. Infragistics has a WebGridExcelExporter that does the job well and needs to be used together with UltraWebGrid.


Streaming files

'Response.AddHeader("content-disposition", "attachment; filename='" & 
Filename & "'")

forces the user to open file, instead showing it in browser window.


Adding events programmatically to a web page

AddHandler oSubmitButton.Click, AddressOf PCRMButtonClicked 



Selecting a whole row in a web data grid (UltraWebGrid). CellClickActionDefault property must be set to RowSelect.


Controls loosing functionality

In case web controls are moved on a page or inside a table, they can be disconnected from the events code. The subs loose their Handles connection and controls fire events that are then not handled in code. Simply write back the Handle part to the sub declaration.