New versions of FireFox allows user to access some keypress properties such as the type, and key code through the "onkeypress" event registration. Not like the old time Netscape, we can access the two properties from the window.Event object.
This is to say, "onkeydown" and "onkeyup" events do not return the two properties at all as expected by some developers (might due to Internet Explorer is returning the two properties?). Some JavaScript code might still be using the old Netscape style which does not work for FireFox.
Sunday, March 21, 2010
Tip: Fire Fox keypress event.
Tuesday, February 23, 2010
Tip: Browser rowspan vs rowSpan when using JavaScript
It's weird that IE7 is case sensitive towards the 'rowspan' property of a table cell. We have to use 'rowSpan' so that IE7 can recognize it and run web page properly. I have tried both the names using FireFox, it was working fine without problem.
For example, this wont work in IE:
table1.cells[0].rowspan = 3;
This will work in IE:
table1.cells[0].rowSpan = 3;
For example, this wont work in IE:
table1.cells[0].rowspan = 3;
This will work in IE:
table1.cells[0].rowSpan = 3;
Thursday, February 11, 2010
Tip: IE8 running on Windows 7 is slow.
Recently I am experiencing slowness on a web site that i am developing. When i tried to scroll down a page, the browser behaves jerky and non consistent. In other words, the scrolling is not smooth like what i tested in FireFox.
After searching much on the Internet, I discovered that some IE plugins might potentially slowing down the browser. Another obvious problem that some plugins can cause is huge memory consumption which eventually slows down the browser significantly. I had this experience whereby the Windows Live plugin actually eats up a lot of memory.
So please turn off all the unused plugins from the browser to make it fast again.
After searching much on the Internet, I discovered that some IE plugins might potentially slowing down the browser. Another obvious problem that some plugins can cause is huge memory consumption which eventually slows down the browser significantly. I had this experience whereby the Windows Live plugin actually eats up a lot of memory.
So please turn off all the unused plugins from the browser to make it fast again.
Sunday, January 3, 2010
Tip: How to replace a fraction digit with a 0 mathematically?
Sometimes for certain reason, we need to replace certain digit in a value with some fix value. Recently i came across this problem to replace the 3rd digit of a fraction of a number with a 0. I can definitely do it with some string manipulation functions such as substring, replace, etc, but it wont be efficient and string manipulation is a costly process when ran in a loop. I need to figure out a way to do it mathematically using a ligther foot print than the string.
Scenario:
to convert a number 1.567 to 1.560
so basically it's to replace the last digit in the fraction with a 0.
Solution:
1. moves the decimal point by multiplying 100 to the value.
double val = 1.567 * 100 [becomes 156.7]
2. get the whole part of the value by truncating it
double w = Math.Truncate(val); [becomes 156.0]
3. minus off the val with the truncated value w.
double left = val - w; [becomes 0.7]
4. move the left value by dividing it with 100
left = left / 100; [becomes 0.007]
5. deduct the orignal value with the left
double answer = 1.567 - left; [becomes 1.560]
Scenario:
to convert a number 1.567 to 1.560
so basically it's to replace the last digit in the fraction with a 0.
Solution:
1. moves the decimal point by multiplying 100 to the value.
double val = 1.567 * 100 [becomes 156.7]
2. get the whole part of the value by truncating it
double w = Math.Truncate(val); [becomes 156.0]
3. minus off the val with the truncated value w.
double left = val - w; [becomes 0.7]
4. move the left value by dividing it with 100
left = left / 100; [becomes 0.007]
5. deduct the orignal value with the left
double answer = 1.567 - left; [becomes 1.560]
Monday, August 3, 2009
Tip: Seting up the WCF wsDualHttpBinding or Duplex Service the correct way.
If you want to use the WCF wsDualHttpBinding to establish a consistent communication between a client and a server (i.e. server to send data to the client consistently), WCF has to create 2 channels that connect from the client to the server and from the server to the client respectively. In order to allow WCF to setup the links correctly, you have to ensure that the client and the server configurations are correct.

Programming a dual binding WCF program will require 2 ports, one for client to communicate with the server and one for the server to communicate back to the client. Basically when debugging a WCF service in your local machine, an example of the server configuration file looks like
The configuration file for the client looks like
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IStockService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" clientBaseAddress="http://localhost:8989/client/"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/DuplexGood/StockService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IStockService1"
contract="ServiceReference1.IStockService" name="WSDualHttpBinding_IStockService1">
<identity>
<userPrincipalName value="FTSB01NB05\ASPNET" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The interesting part lies in the client configuration file where the two bolded lines of text from top to bottom, represent the client port and the server port respectively. If you did not specify any of the address correctly you will probably receive the following error:
HTTP could not register URL http://+:80/client/ because TCP port 80 is being used by another application.
The error above indicates that you set your client port number the same port number as the server.
OR
There was no endpoint listening at http://localhost:8989/Services/StockService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The error above indicates that the server endpoint is specified incorrectly and that WCF failed to find the service.
The server configuration looks like the following
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="mexBehavior" name="EssentialWCF.StockService">
<endpoint address="" binding="wsDualHttpBinding" contract="EssentialWCF.IStockService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Thursday, July 16, 2009
Tip: How to hide datagrid column in Windows Mobile 6.1
Scenario:
I have a datagrid that contains 3 columns; Product Code, Product Package, and Quantity. However, the datasource of the datagrid is a datatable with the name "ProductList" that contains Product Id, Product Code, Product Description, Package, and Qty. When the datatable is binded to the datagrid, all the fields in the datatable are shwon in the datagrid. So how do we hide those unwanted fields from showing in the front end?
Solution:
1. Create a DataGridTableStyle for the DataGrid and add in the styles for column: Product Code, Product Package, and Quantity.
2. In the DataGridTableStyle "MappingName" property, makes sure you put in "ProductList" as the value. This value tells the DataGrid to map the fields to the "ProductList" table and to hide those fields that are not stated in the GridColumnStyles collection.
Monday, July 13, 2009
Tip: Microsoft Service Factory Host Model Insight - The needs to include the "Service Implementation" layer.
Whether you are developing a WCF or ASMX service, the Microsoft Service Factory Host Model allows user to add in ".svc" or ".asmx" files that can be accessed from within a "Website" project that you will host using IIS. However, the problem is we cannot use the standard ASP.NET Application project to fit into the host model designer. The designer only recognize "Website" project and hence you wont be able to update the web.config or even add in the ".svc" file into the project using the designer. Even worst is, the "Website" project does not generate the necessary "Website.dll" file when you compile the project. This prevents you from generating the necessary proxy for your service when you execute "Add Service" function.
If you observed the example that comes with the Service Software Factory, you will notice that it contains another layer called the "Service Implementation". This separate dll in the solution represents a dll that you can include into the "Website" project that acts as a host for the service(s) that you are going to expose. By including the dll in the "Website" project, you will not have problem accessing the service(s) in the Host Model designer.
Subscribe to:
Posts (Atom)