Archive for the ‘Uncategorized’ Category

Microsoft HTTPAPI/2.0 use Port 80 – Cannot Start WAMP Apache

Saturday, December 10th, 2011
Screenshot of Microsoft Web Deployment Service

Microsoft Web Deployment Service

I just installed fresh Microsoft Windows 7, and I installed WAMP for my APACHE – PHP server. When I want to start the server, the WAMP icon turn yellow (not green). Upon further investigation, I found out that when I go to WAMP dock icon -> Apache -> Service -> Test Port 80, I received a message that Port 80 is used Microsoft HTTPAPI/2.0.

I fire up Google and most of the solutions mentioned about turning off Microsoft SQL Server Reporting Services (SSRS). I have browsed my Services and couldn’t find any SSRS installed (although I have SQL Server 2008 Express installed).

Luckily I came across this forum which gives me the solution.

We must stop Web Deployment Agent Service (MsDepSvc) from Administrative Tools > Services area. You can disable the service, to have port 80 ready when you boot your system.

The following article will explain about this service, you can follow the link below to read more.

Microsoft Web Deploy

Web Deploy is a free technology built by my team that can improve web deployment. It is a deployment service that runs on a server, and enables you to either locally or remotely deploy applications onto it. Web Deploy includes built-in support for creating virtual directories and applications within IIS, copying files and folders, provisioning databases (both SQL Server and MySQL), setting file-system ACLs and more (it even includes built-in providers for things like setting registry entries, registering COM components, etc). In addition to having these built-in deployment features, it also supports a .NET based provider API that enables you to create and plug-in your own custom deployment actions – which allow you to customize it however you want.

http://weblogs.asp.net/scottgu/archive/2010/09/13/automating-deployment-with-microsoft-web-deploy.aspx

How it works: ASP.NET Custom Validator

Thursday, June 23rd, 2011

This time I will highlight how ASP.NET validator works (in particular the Custom Validator). This control has almost the same attributes as the other validation controls, but with Custom Validator you can specify your own method (Server code and Client script) to validate.

When to use ASP.NET Custom Validator?

Custom Validator is a suitable for the following scenario:

  • Validating checkbox (Agreements, Terms and Conditions checkbox). Please note that you cannot use Required Field validator for check box control.
  • Validation that involves multiple controls. For example: provide at least one telephone number from three available inputs (mobile, work phone, and home phone text boxes).
  • Validation that involves certain calculation or custom logic

How to use ASP.NET Custom Validator

You can assign two validation functions into Custom Validator. They are Server side in code behind and client script (VB or JavaScript).

  1. Create the server side function in code behind to validate the values in server (mandatory). This is important because we do not have control over the client script and it can be easily bypassed.
    Public void ServerValidation (object source, ServerValidateEventArgs arguments)
    {
    int i = int.Parse(arguments.Value);
    arguments.IsValid = ((i%2) == 0);
    }
  2. Create the client side JavaScript function to create validation on client side.
    <script language="javascript">
    function ClientValidate(source, arguments)
    {
    if ((arguments.Value % 2) == 0)
    arguments.IsValid=true;
    else
    arguments.IsValid=false;
    }
    </script>

Your Control will look like

<asp:CustomValidator id="CustomValidator1"
ControlToValidate="Text1"
ClientValidationFunction="ClientValidate"
OnServerValidate="ServerValidation"
Display="Static"
ErrorMessage="Not an even number!"
runat="server" />

Why Custom Validator is not working

  • Do not set ControlToValidate, if you want to validate multiple fields. Since Custom Validator will not run if the ControlToValidate is empty value.
  • Call Page_ClientValidate(); in JavaScript and Page.IsValid in Page Behind to check if the validation is fulfilled.

Further Information

http://msdn.microsoft.com/en-us/library/9eee01cx%28VS.90%29.aspx

Floating Element Causes Disappearing (Phantom) Background Image CSS in IE7, IE6

Thursday, January 13th, 2011

Symptom: When you set background image in a div, and have a floating element on top of the background image, it will cause the image to flicker, disappear, or missing some part of the image. This happens when you scroll the page up and down and occur in IE prior version 8 (mainly I experienced it in IE7 and IE6).

If you have been working with HTML and CSS for a long time, you should be familiar with this bug. If it’s not, then probably you haven’t done something advanced in your design.

Solution:

  1. You can set the element with background to have relative position.
    #div1 { background: url(‘../images/bg.jpg’) top left no-repeat; position:relative; }
  2. Or, you can set the height of the DIV with the background. Easiest way is to have CSS specific for IE6 / IE7 and set the height to 1%
    #div1 { background: url(‘../images/bg.jpg’) top left no-repeat; height: 1%; }

How to check for User Role in Microsoft Dynamic CRM 4.0 in Form Script

Thursday, November 19th, 2009

By using Microsoft Dynamic 4.0 form script capabilities, you can easily get the current user role. This ability will help you to create custom javascript to provide another level of user interaction. The script below will give you an example to grab all the roles assigned to the current CRM user.

First of all to make our life easier, as we do not need to reinvent the wheel (creating library to connect to CRM Web Service). Thanks to the guys at Ascentium, they have created a Microsoft Dynamics CRM JavaScript SDK which you can freely download at:

http://xrm.ascentium.com/blog/crm/Post129.aspx

For this example purpose, Copy and paste the Acentium CRM SDK javascript to the Form Onload of any entity.

Then below that, we can add our own code that refer to the script. Copy and paste the following.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// BEGIN:  ferolen  get the crrent user role scripts
var VALID_ROLENAME = "AdminGuy";
if (! UserHasRole(VALID_ROLENAME)) {
   // Do something if the user does not have the role
}
 
function UserHasRole(roleName)
{
   //create the Ascentium_CrmService object
   var oService = new Ascentium_CrmService();
   var xml = " ";
   var aoFetchResult = oService.Fetch(xml);
   for (var i = 0; i &lt; aoFetchResult.length; i++) {
      var beResult = aoFetchResult[i];
      if (beResult.attributes["name"].value == roleName) return true;
   }
   return false;
}
// END : ferolen  get the crrent user role scripts

Setting http Proxy for Java Application

Monday, February 16th, 2009

There are 2 main ways to set/configure http proxy in your java application.

  • As a command line option when invoking the VM
  • Using the System.setProperty(String, String) in your code

There are 3 properties you can set to specify the proxy that will be used by the http protocol handler:

  • http.proxyHost: the host name of the proxy server
  • http.proxyPort: the port number, the default value being 80
  • http.nonProxyHosts: a list of hosts that should be reached directly, bypassing the proxy

Example of using command line option to set proxy configuration on java
java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080
-Dhttp.noProxyHosts=”localhost|host.mydomain.com” YourAppMainClass

Example of using code to configure proxy setting on java
//Set the http proxy to webcache.mydomain.com:8080
System.setProperty("http.proxyHost", "webcache.mydomain.com");
System.setPropery("http.proxyPort", "8080");
// Next connection will be through proxy.

There are other proxy settings that you can set as well such as https, ftp, socks.
More resources:
http://java.sun.com/javase/6/docs/technotes/guides/net/proxies.html