Sunday, August 28, 2011

Target framework ASP.NET 4.0, setting clientID (s) : ClientIDMode property

When target version is "ASP.NET 4.0", it follows different pattern while generating the client IDs. The new framework introduces the ClientIDMode property which can be used to set the way we want the client IDs to be generated. This is a very good decision from Microsoft to allow developers set what they want.

We have a standard pattern until ASP.NET 4.0,  the algorithm for generating the id attribute from the ClientID property has been to concatenate the naming container (if any) with the ID, and in the case of repeated controls (as in data controls), to add a prefix and a sequential number. While this has always guaranteed that the IDs of controls in the page are unique, the algorithm has resulted in control IDs that were not predictable, and were therefore difficult to reference in client script.


This has its own pros and cons where we cannot predict the client IDs and the client IDs would be very long and sometimes considerably increases the page size for large pages.

These are the four values that can be set to this property


ClientIDMode property:
  • AutoID – This is equivalent to the algorithm for generating ClientID property values that was used in earlier versions of ASP.NET. If you want the existing behavior as in previous versions set this property to "AutoID"

  • Static – This specifies that the ClientID value will be the same as the ID without concatenating the IDs of parent naming containers. This can be useful in Web user controls. Because a Web user control can be located on different pages and in different container controls, it can be difficult to write client script for controls that use the AutoID algorithm because you cannot predict what the ID values will be.

  • Predictable – This option is primarily for use in data controls that use repeating templates. It concatenates the ID properties of the control's naming containers, but generated ClientID values do not contain strings like "ctlxxx". This setting works in conjunction with the ClientIDRowSuffix property of the control. You set the ClientIDRowSuffix property to the name of a data field, and the value of that field is used as the suffix for the generated ClientID value. Typically you would use the primary key of a data record as the ClientIDRowSuffix value.

  • Inherit – This setting is the default behavior for controls; it specifies that a control's ID generation is the same as its parent.
We can set this property at the page as well as control level, for more detailed information on this property please refer to the following link : http://www.asp.net/learn/whitepapers/aspnet4 

We can set this property to "AutoID" to restore the behavior in the previous version.

Object doesn't support this property or method - window showmodaldialog

This is one of the strange errors from internet explorer 8 when a show modal dialog is attempted to be shown. This error occurs when popup blocker is active on IE.


Resolution: Make sure your popup blocker is not blocking any popups for the website and this should work perfectly fine.


Sunday, August 7, 2011

DIV scroll top and bottom using Jquery

This post gives one way to have a scroll bar to a div tag at the top and bottom as shown in the picture.

The high level overview of the implementation:
  1. Added an empty div on top the div that has scrolling.2. Set the width same as the below grid or with excluding the vertical scroll bar width (around 18px) if we need not show vertical scroll for the top div
  2. Placed an empty table in the top div and width will be same as the table/grid in the bottom div
  3. Included a juery file and overridden the scroll event which will synchronize the horizontal scroll bar
Output:




















download source: DIV top and bottom scroll sample htm page and source

Note: I have included the complete jquery script in the above source so that the htm page works independently. You may just need to include jquery file instead. Run the source file and it is self explanatory.


Name or Password is incorrect (repeat logon) SAP RFC

Recently we have got a new application went to production environment and we stuck up with this issue in the production from RFC connector.

Error Information:


Type : SAP.Connector.RfcLogonException, SAP.Connector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=50436dca5c7f7d23
Message : Name or password is incorrect (repeat logon)
Source : SAP.Connector
Help link :
ErrorGroup : RFC_ERROR_LOGON_FAILURE
ErrorCode : RFC_ERROR_LOGON_FAILURE
Data : System.Collections.ListDictionaryInternal
TargetSite : Int32 Open()
Stack Trace : at SAP.Connector.Connection.Open()
                                              


After several different tries changing passwords, Here is what we concluded to be on safer side while creating a password

1) Not more than 8 characters
2) No numbers, only alpha and all upper case

Once we reset our password to match the above criteria the RFCLogonException is gone and we are able to connect.