Category Archives: ASP.NET

Compare 2 source files and add difference to 3rd

Beyond Compare 3-way merge

Sometimes when you patch or update your current version of software there is a need to apply the same changes to a previous version. Ordinary it’s a pain – you need to painstakingly determine which changes from the current source should go to previous version (because current source has changed a lot, new features added etc).

Enter Beyond Compare – coolest tool to do all kind of compassion. One of the best features – “3 way merge”. It allows you to compare 2 files and apply the difference to 3rd.

In our case here is what it can do:

  • Select new patched version of source file and compare it to old unpatched version
  • In menu select “Session –> Merge Files” – a middle pane appears that allows you to select 3rd file
  • In the middle tab select new unpatched version

That’s it! Beyond Compare will compare new patched and new unpatched version. If there’s a difference – those lines will be applied to old unpatched version. Otherwise if both new versions are the same – old version keeps it lines, even though they’re different from new version.

It’s all performed automatically all you have to do in the bottom pane (where merge result appear) select the filename to save to and hit “Save”

Infragistics WebDataMenu delayed resizing in Chrome

I encountered weird issue using Infragistics ASP.NET WebDataMenu control. If total width of top-level items was bigger than menu’s width and scrolling kicked in – Google Chrome browser produces unexpected results.

Consider following basic markup for Infragistics WebDataMenu:

<ig:WebDataMenu ID="WebDataMenu1" runat="server" Width="300px">
   <ClientEvents Initialize="myInit" />
   <GroupSettings Orientation="Horizontal" />
   <Items>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
      <ig:DataMenuItem Text="Root Item"></ig:DataMenuItem>
   </Items>
</ig:WebDataMenu>

It’s a pretty basic markup that defines 10-item horizontal menu with a limited width, so scrolling is enabled. Code in the Initialize event handler would handle some calculation based on menu dimensions and other items on the page would be affected by these calculations. Continue reading →

Infragistics WebDataMenu flashes unexpected color on hover

WebDataMenu
Infragistics WebDataMenu ASP.NET control comes both with predefined stylesets and allows you granularly overwrite any of the styles. For example definition like this

<ig:WebDataMenu ID="xmyMenu" runat="server" StyleSetName="Office2007Blue"
                 CssClass ="topMenuStyle" >
   <GroupSettings Orientation="Horizontal" />
   <ItemSettings CssClass="itemCssStyle" 
                 HoverCssClass="hoverCssStyle" 
                 SelectedCssClass="selectedCssStyle" />  
</ig:WebDataMenu>

will create a horizontal dropdown menu in default “Office 2007 Blue” styleset but allows you to overwrite individual styles via exposed CSS properties.

Let’s take a look at hover style. Continue reading →

Infragistics WebDataGrid stalls on paging large datasets

A common scenario while using Infragistics WebDataGrid is to have an unbound column, whose cell’s value is determined at runtime in InitializeRow event, something like

Private Sub xmyGrid_InitializeRow(ByVal sender As Object, ByVal e As GridControls.RowEventArgs) Handles xmyGrid.InitializeRow
   '... some code
   e.Row.Items(0).Value = SomeCalculatedData
   '... some more code
End Sub

This works fine if you bind the grid to a small data set (and you should!) But if, due to circumstances out of your control, you bind it to a dataset with tens of thousand of records you might be screwed. Even if you enable paging (and you most definitely should!) you may find yourself living in a shotgun shack in a situation that changing page takes forever and eventually crashes. If you do – change the above line to

e.Row.Items(0).Text = SomeCalculatedData

note using of .Text property, which is String, instead of .Value which is Object. Since you’re assigning the calculated data for presentation only – no need to change underlying value – and this makes all the difference.

Flipping pebbles

Big Flip Clock

As far as smartwatches go – Pebble is a lot of fun. But after playing around with Watchface Generator, Canvas for Pebble and numerous other apps I wanted something more, something that only Pebble SDK could provide. A coder in me wanted to code.

Enter CloudPebble – an amazing online development environment that runs in your browser, has a full-blown C compiler and connects to your watch to run/debug compiled apps. Plus your projects are stored on the cloud and available anywhere you can get online.

Yes you program Pebble in classic C – and it’s a lot of fun. And my first real attempt at custom watchface (pictured above) is old-style flip clock, you can get it here. It is based on amazing pebble bitmap library by Gregoire Sage

Display “Lose It!” data on Pebble watchface

Original Lose It!Lose It! on Pebble

Lose It! is an excellent service that helps people lose weight by monitoring calories intake. It integrates with variety of devices so I was curious if I can display my user data on Pebble smartwatch (to make sure I can have another piece of cake or not).

Unfortunately LoseIt doesn’t have a public API. There had to be another way. Continue reading →

How to receive Stack Overflow notifications on your phone and smartwatch

If this then that

As you may have gathered I am a frequent participant of Stack Overflow Q&A board for coders. On that site everytime somebody responds to your question or comments – a notification is displayed in the status bar. Ditto when your reputation points change.

I became curious whether I could receive these modifications on my phone. Stack Exchange released their own application on Google Play store that does send push notifications when a reply is received, but no notifications on reputation changes. Also it’s still a little rough around the edges and besides I realized I didn’t want a full blown Stack Overflow application (when I do use SO for questions/answers I prefer the full site on my laptop). There should be another way. Continue reading →

Infragistics WebSplitter: Set SplitterBar’s CSS class in clinet-side JavaScript

Hello there. Haven’t written in a while, been busy participating in Stack Overflow community, but this little bit I found interesting.

Infragistics has a cool versatile Web Splitter control in their ASP.NET suite, but recently I encountered a shortcoming – there’s no way to set a CSS class for splitter bar on client-side via JavaScript. On server-side you can do something like

xMySplitter.SplitterBar.CssClass = "hiddenElement";

On client-side – you can get the CSS class via

var sCss = $find('xMySplitter').get_splitterBarCss()

but there’s no counterpart set_splitterBarCss() method. Continue reading →

WebHierarchicalDataGrid: get_scrollTop() returns incorrect value

Infragistics WebHierarchicalDataGrid has a neat client-side built-in function get_scrollTop() – it is used if at any point you need to retrieve current vertical scroll position of the grid (e.g. to use it in your own calculations to display something at a specific position on the grid – tooltip, help, additional info etc.)

Unfortunately the function has a bug: its value only set if user actually manually scrolls the grid: using mouse and scrollbar on the right, keyboard etc. If no scrolling user-interaction is involved and scroll position changes due to other means (e.g. displayed data size changes) – the function retains original value, throwing all your calculation out of whack. Continue reading →

Disable WebDataTree in client-side JavaScript

Let’s say you’re using Infrafitics WebDataTree’s server-side SelectionChanged event to perform some action when user selects a tree node. Now let’s say there’re times when you need to disable tree-selection (for example another control, e.g. WebDataGrid is being updated and clicking tree node during update will mess things up). Also you need to do it in client-side JavaScript (e.g. if that second control is inside of UpdatePanel – server-side updates will not affect controls outside the panel).

What to do? WebDataTree doesn’t have CSOM set_enabled() method and if you use client-side DOM’s:

$find('xMyTree').get_element().setAttribute('disabled','true');

tree may take appearance of being disabled in some browsers, but user can still select nodes.

Fortunately there is a solution (thanks Bhadresh from Infragisitcs techsupport for suggesting it). WebDataTree has SelectionType property (0 = None, 1 = Single, 2 = Multiple) that controls how many nodes can be selected in the tree. It also has a counterpart in client-side JavaScript set_selectionType(), so in order to disable selection simple use command

$find('xMyTree').set_selectionType(0);

Later on selection can be re-enabled either by passing 1 to above function or even server-side by calling

xMyTree.SelectionType = NavigationControls.NodeSelectionTypes.Single