October 2007 Entries

Javascript -dynamically change the width of one table based on the size of other table.

I need to ensure that the width of one table on my html page be calculated from the width of other table. (less for determined value). Currently the size is hardcoded in the Server user control code. But ideally it could be done using Javascript - to dynamically change the width of one table based on the size of other table. The Task looks very strightforward, but I decided to post a few links, that I found interesting: Dynamic Content with DOM-2 :JavaScript | Table and in particular Q1594 How can ......

Watin Test Recorder helps to navigate to required for debugging page.

It is quite common, that a developer needs to do a few (sometimes time-consuming) steps to navigate to the pages that are required debugging. And if you do some non-trivial change, Edit&Continue doesn't work, and you have to start debugging again. Yes, I know, that small unit tests should cover all the code paths and make debugging redundant. Unfortunately in the real life debugging is sometimes unavoidable. Watin Test Recorder allows to record the navigation steps and save it as a console executable(or ......

DataView.Sort doesn't accept long name for direction

According to the documentation DataView.Sort is a string that contains the column name followed by "ASC" (ascending) or "DESC" (descending). Columns are sorted ascending by default. Multiple columns can be separated by commas. If you pass long name: Descending or Ascending (from System.Web.UI.WebControls.S... enum) the error is reported: System.IndexOutOfRangeExcep... Cannot find column LastName Descending. at System.Data.DataTable.Parse... sortString) at System.Data.DataView.Update... ......

EnitySpaces: the same Query can be used to save multiple tables

I wanted to minimize number of calls to the database, but get back results of dynamic query for small number of columns, as well as detailed data(e.g Itinerary table and Itinerary joined with Itinerary items) .In EntitySpaces I've created a where condition, filled Query and loaded detailed data, then saved the returned table to DataSet. Then for the same query I've specified distinct select columns and Load it again(When LINQ will be available, it could be done in memory without extra database call). ......

SQL Server Seminar presented by Kevin Kline

Last week I was on SQL Server Seminar presented by Kevin Kline. Performance, Baselining, Benchmarking and Monitioring Presentation Stored Procedure Best Practices Presentation Surviving the Data Avalanche Presentation Top 10 Mistakes on SQL Server Presentations There were a few interesting points. •Causes of performance problems-5%-hardware, 15%-bad database design, 80%-bad application code. •Do not Interleaved DDL and DML -No create/Drop table in the same SP as insert/Select. •Keep transactions ......

Issues using binary serialization to store object state for unit tests

To save object state for unit tests we use binary serialization. The object state saved to data file and at the start of the test is loaded from the file. It works OK until the object will be changed in a new version. Fortunately There is no problem when a new field is added, but if a field is deleted or removed, it most likely will cause deserialization exception(see Version Tolerant Serialization, Net Serialization FAQ, Solving Binary serialization versioning conflicts articles for details). Also ......

Ensure that JavaScript files or CSS files are refreshed for each new version

We can add into references to JS or CSS files from HTML: <SCRIPT TYPE="text/JavaScript " SRC="FileName.js?v=<%=As... The attribute does nothing other than trick the browser into thinking that the .js file must be retrieved from server for new version instead of cached . You can write your own AssemblyVersionNumber() function or use my function from My SystemHelper class. like the following: SystemHelper.GetAssemblyVer... Idea from ......

Generic function to Find Duplicates in Generic List

I've created a new function to Find Duplicates in Generic List similar to Generic function to removeDuplicates from Generic List as well as bool AreValuesUnique. ]]> public static List<GenericType> FindDuplicates<GenericTy... inputList) { Dictionary<GenericType, int> uniqueStore = new Dictionary<GenericType, int>(); List<GenericType> finalList = new List<GenericType>(); foreach (GenericType currValue in inputList) { if (uniqueStore.ContainsKey(cu... ......

EntitySpaces API: How to get esQueryItem column name.

In constructor columnName is passed as parameter. public esQueryItem ( esDynamicQuery query, string columnName ) However I wasn't able to fint the property ColumnName or something similar.After some time I understood, that they use implicit operator stringpublic static implicit operator string ( esQueryItem item ) which does the magic. However the explicit read-Only property ColumnName will be useful. By the way the help shows 2 different operators as the sameImplicit(esQueryItem)To... (to use ......

DataGrid to GridView Conversion changes

I created a table describing, which fields/elements I had to change when converted existing DataGrid to GridView . Mapping for some other elements can be found in the article here. asp:DataGrid asp:GridView Comment asp:TemplateColumn asp:TemplateField asp:BoundColumn asp:BoundField AlternatingItemStyle AlternatingRowStyle ItemStyle RowStyle or TableItemStyle DataGridItemEventArgs GridViewRowEventArgs ItemDataBound event RowDataBound not DataBound DataGridItemEventHandler ItemCreated event RowCreated ......

Custom DropDownList with DataBind and extra option "Please Select"

There is a common requirement to have DropDownList populated from Collection(e.g.DataTable) with extra (usually default) option "Please Select". I wanted to find a custom control that will allow to specify this extra option and use standard DataSource/DataBind. I wasn't able to find it in Google, so probably I will write it myself. Relevant links to consider:An ASP.NET 2.0 AutoComplete DropDownList... 'Dropdown1' has a SelectedValue which is invalid MetaBuilders.ComboBox[^] ......

Stop background find in "visual studio" not always stops search

In VS 2005 (I have SP1) it is a toolbar icon called “Stops a background Find”, that suppose to cancel the find . However I noticed on my machine and on my colleage's machine, that sometimes VS hangs on searching(shows the search as processing, but doesn't change the filename on status bar).The button nether shortcut (Alt-F3,S) doesn't stop search and you need to close VS to re-enable searching. I don't have enough details to reproduce the problem, so it is pointless to report to MS Feedback site ......

asp:PlaceHolder can be put within html table, if the table is not runat="server"

I had a table in user control, taht included asp:PlaceHolder. In the code some other user controls are loaded into the placeholder. <table cellSpacing="0" cellPadding="0" border="0" > <TR> <TD >Header</TD> </TR> <asp:PlaceHolder id="plc1" Runat="server"></asp:... <table> It worked fine until I decided make the table conditionally invisible based on some server logic. I've added an ID ans runat="server" to the table and got an error: System.Web.HttpCompileExcep... ......

NullReferenceException in EntitySpaces_C#_ASPX.csgen template after copy template instance

I am using MyGeneration Project to generate admin web pages using EntitySpaces Templates for ASP.NET . Filling templates is very time consuming, and I decided to copy template instance for one table as a start point for other table. It didn't save much , because it require you to do everything differently for each table anyway. And it also causes an errors. I've done selections im multiple tabs, but when I Executed template instances, I've got errors **ERROR*** [NullReferenceException] Object reference ......

Generic LoadFromCache method to reliably read data from cache.

The typical procedure to work with cache is 1.to check if item for specified key exist in a cache; 2.if yes, return it; 3.if no, create it (e.g load from database), 4.save to the cache 5. and then return it. Some developers use the code like the following: If (DataCache.GetCache["key"] == null) { // code for loading object ... DataCache.SetCache("key", obj); } return DataCache.GetCache["key"]; //Not good, can cause problems (at least in ASP.Net 2.0). Sometimes SetCache is not effected immediately(or ......

SQL Server Stored Procedure Naming Standard Recommendations

I've included a few articles that recommend similar but slightly different SP naming standards: SSW SQL Stored Procedure Naming Standard [proc] [MainTableName] By [FieldName(optional)] [Action] e.g procClientRateSelect' Practical Methods: Naming Conventions Prefix all stored procedures with "p". Complete the name with the primary table affected, then the job performed. This will group all procedures for a given table in one location alphabetically. Samples: pCustomerList, pCustomerSearch, pCustomerCreate, ......

To cache in asp.net individual items or one dictionary ?

I have a reference data, loaded from database table in ASP.NET application. I wanted to store some of the records in the cache, but only those that were called by some user, not the whole table. I considered to options: 1. to store individual items directly in the HttpRuntime.Cache dictionary with some composite string key(e.g. "MyTableName:"+ Row.Key.ToString()). 2. create new Dictionary<KeyType,Table... and add the loaded records to the Dictionary. The dictionary itself should be ......

T-SQL User defined function to concatenate column to CSV string

I had a complicate (and buggy) T-SQLstored procedure, that concatenate fields from details table and show them as one field in the resultset of the main table(Itinerary and summary of itinerary items. I've looked in pivot functionality, but didn't fint how to make it working in the way I needed. Furthermore, Pivot is available for SQL Server DB with compatibility level 90(aka SQL server 2005), but our db still has compatibility level 80(aka SQL server 2000). So I desided to write UDF to concatenate ......

«October»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910