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 I detect the width of a table?

JavaScript DOM Examples

Controlling Table Size 

Advertisements

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 Windows forms test harness).
Then run the executable, and Watin script will fill all the forms and navigate through multiple pages. You can just set breakpoints in your ASP.NET application and wait until your code will be reached.
I want to confirm that v1.0 of  Watin Test Recorder  is quite stable and produce workable scripts(Beta versions didn’t do the job well).

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.SortDirection enum)

the error is reported:

System.IndexOutOfRangeException: Cannot find column LastName Descending. at System.Data.DataTable.ParseSortString(String sortString) at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent) at System.Data.DataView.UpdateIndex(Boolean force) at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter, Boolean fireEvent) at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, DataExpression newRowFilter) at System.Data.DataView..ctor(DataTable table, String RowFilter, String Sort, DataViewRowState RowState)

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).  Different table was created, that I’ve added to the same dataset. Below is code snippet:

                VwItinerariesCollection collPendingList = new VwItinerariesCollection();
                VwItinerariesQuery queryFilter = collPendingList.Query;
                queryFilter.AddWhereConditions();//custom code
                 collPendingList.Query.Load();
                 DataTable tbl= collPendingList.ConvertToDataTable();
                tbl.TableName = ListWithDetailsTable”;   
              DataSet  itineraries = new DataSet();
                itineraries.Tables.Add(tbl);
                 queryFilter.DistinctSelectForList();//custom code
                 collPendingList.Query.Load();
                 tbl = collPendingList.ConvertToDataTable();
                 tbl.TableName = ListTable”;
                 itineraries.Tables.Add(tbl);

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 as short as possible.Use @@TRANCOUNTor sys.dm_tran_active_transactionsto look for orphaned transactions when entering a new routine.

Set Theory is Better. then rows.Cursors are depricated.
Use table variables,minimize use of tempdb
Again: Set Nocount On
Again: Owner qualify all names (2-part)

Tiered storage:
Active(e.g. RAID10, high RPM speeds).
Near-term older data (e.g. RAID5, middle RPM speeds)
Old, long-term data (e.g. SATA drives – high volume, low RPM speeds)

Related white papers from Quest Site(login probably will be required):

The Top 10 Mistakes on SQL Server
Tuning SQL Statements on Microsoft SQL Server
Finding and Fixing Bad SQL in Microsoft SQL Server 2000
Performance Baselining, Benchmarking, and Monitoring for SQL Server 2000

Microsoft T-SQL Performance Tuning Part 1: Analyzing and Optimizing T-SQL Query Performance on Microsoft SQL Server using SET and DBCC 

Microsoft T-SQL Performance Tuning Part 2: Analyzing and Optimizing T-SQL Query Performance on Microsoft SQL Server using Indexing Strategies  

Microsoft T-SQL Performance Tuning Part 3: Analyzing and Optimizing T-SQL Query Performance on Microsoft SQL Server using Query Optimizer Strategies

Microsoft T-SQL Performance Tuning Part 4: Analyzing and Optimizing T-SQL Query Performance on Microsoft SQL Server using SHOWPLAN Output and Analysis
Virtualization and SQL Server in the Enterprise

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 FAQSolving Binary serialization versioning conflicts articles for details).

Also changing return type will break deserialization. E.g. I’ve changed return type from ArrayList to type-safe List<MyType> and I’ve got errors.

I wanted to change the storage to use SoapFormatter to be able to read and optionally modify the data file, If it’s broken.
(Similar approach described by Mauro Sturaro  in discussion here)

But SoapFormatter does not support generics and beginning with the .NET Framework version 3.5, this class is obsolete.
Dino Esposito suggests to consider LosFormatter Class -but it is not human-readable, like binary.

Dictionary with keys from enum.

One of our classes keeps state in a dictionary of attributes, with the keys from enum. Adding new values to enum do not causes deserialization exceptions, But the problem was that enum didn’t have explicit assignments for numbers, but used automatic increment. When someone inserted a new key into enum, actual enum values were shifted, and all dictionary was corrupted.
The highly recommended way is to explicitely assign values for enum . Do not forget to have defualt value for 0- e,g, NonInitialized.
I’ve created a  helper functions AreValuesUnique<EnumType, ValueType>() and  List<ValueType> FindDuplicates<EnumType, ValueType>() to ensure that explicit values are not duplicated and I am calling it from unit test.

Based on these problems I don’t like to store objects for unit test using binary serialization.
I am going to research, which other options are viable. 

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=<%=AssemblyVersionNumber()%>”>

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.GetAssemblyVersion(Assembly.GetExecutingAssembly())

Idea from http://www.thescripts.com/forum/thread165240.html

Note that it could be  problems, if head element has runat=”server” attribute.

Also consider to reduce number of CSS and JS files.