>
 



Recently, I have written a C# wrapper for Google Closure Compiler to use with ASP.NET for on-the-fly JavaScript compression. For those who want to use the Closure Compiler with PHP, Bohuco.net has an article showing how to use the Google Closure Compiler over its RESTful API with PHP5.  

$script = file_get_contents('http://www.domain.com/scripts/script.js');
$ch = curl_init('http://closure-compiler.appspot.com/compile');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($script));
$output = curl_exec($ch);
curl_close($ch);

You can find more details on using Closure Compiler with PHP 5 here.

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5



On November 5th, Google released Closure Compiler for Javascript optimization. The strongest part of the Closure Compiler is that it does not only remove whitespace but also rewrites Javascript Code to make it smaller. It also optimizes your Javascript code to perform better. You can find more details and all of its features on my previous article: Closure Compiler – Javascript Compiler by Google.

During my tests, Closure Compiler reduced Javascripts more than 60%. Considering, the size of Javascript files that modern websites have and the reduction before HTTP compression, Closure Compiler is really useful. 

Closure Compiler comes with a Java based command line tool and a RESTful API.  RESTful API works great and very fast. API can be used with a MSBuild or NAnt script to automatically compress Javascript files.

I wrote a C# wrapper for the Google Closure Compiler:

Google's Javascript compressor - C# wrapper
C# wrapper for the Google Closure Compiler

 

More...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5



Kentico CMS is a powerful, flexible and complete content management system which provides a complete set of features with an affordable price.

Kentico CMS – built on the Microsoft ASP.NET platform - comes with an easy-to-use WYSIWYG editor for creating/editing the content for building web sites, blogs, community sites, intranets and online stores. It has various modules that make building any type of website and manage its content possible. It comes with an API that allows you to script operations such as creating a new document, user, or editing an existing document. The API is great for integrations with any 3rd party software.

Kentico CMS WYSIWYG Editor
Kentico CMS WYSIWYG Editor

 

Kentico CMS lets you create and maintain articles, newsletters, forums, blogs, polls, news, wikis, product listings, FAQs, and knowledge-base articles. It also comes with a module for implementing e-commerce functionality into your website with support for search-engine optimization (SEO). In addition, Kentico generates SEO-friendly URLs, has full-text search support, a powerful role-based security system. Also, it supports multiple languages including Chinese and languages written from right-to-left such as Hebrew and Arabic.

Kentico CMS promises to fix any bug within 7 days, and in addition they plant a new tree with the name of the bug reporter. You can find more details here.

Kentico CMS for ASP.NET is available in four editions: Free, Professional Edition, Enterprise Edition and Social Networking Edition. The core features are the same for all these editions, but some advanced features are not available in the Free and Professional editions. The free edition have no time limitation and can be used for commercial purposes without aqny extra cost. It can be downloaded from here.

Kentico CMS is available in four editions
Kentico CMS is available in four editions

 

Besides TRIAL and FREE editions, the Virtual Lab service allows users to test Kentico CMS on-line for 7 days, without the need of installing anything on users’ local PC. To sum up, Kentico CMS is a powerful, flexible and reliable content management system, used by more than 4000 web sites in 83 countries and the clients include Microsoft, Brussels Airlines, Vodafone, Audi, Mazda, Subaru, Samsung, Gibson, Bayer, ESPN, Guinness, DKNY, Abbott Labs, Medibank Private (Australia), Ireland .ie and others.

Currently rated 4.3 by 6 people

  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tag : , ,
Categories : All | ASP.NET
Share & Support : del.icio.us | DZone it! | Kick it! | digg it! | Furl | Technorati



If you try to use Enter key in ASP.NET, according to your browser type, you can get really weird results. In my previous article Default Button in ASP.NET 1.1, I described two methods to make enter key default button for form inputs in ASP.NET 1.1.

Fortunately, ASP.NET 2.0 makes this easier by introducing a concept of "default button" that can be used with either a <form> or <asp:panel> control. What button will be "clicked" depends of where acutally cursor is and what button is choosen as a default button for form or a panel.

For example, with the below sample:

<html>
<body>
   <form defaultbutton=“button1” runat=“server”>
      <asp:button id=“button1” text=“btn1” runat=“server”/>
         <asp:panel defaultbutton=“button2” runat=“server”>
            <asp:textbox id=“textbox1” runat=“server”/>
            <asp:button id=“button2”  text="btn2" runat=“server”/>
          </asp:panel>
    </form>
</body>
</html>

If the enter key is selected the first time the page is loaded, "button1" will be the button that receives the post-back event. If the enter key is hit while the user has their cursor focus within the "textbox1" textbox (contained within the <asp:panel>), then "button2" will be the button that receives the post-back event. 

Currently rated 3.5 by 4 people

  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5



Hitting the enter key in a TextBox may sometimes cause undesired effects in ASP.NET 1.1. For example, the wrong submit button's click event may be triggered or no click event of any button is triggered.

Suppose that, you have one ASP.NET textbox and a button in a web form and OnClick event of the button contains the following code:

Response.Write("Clicked");

If you press the enter key when the textbox has focus, the form will be submitted but button's click event will not be executed.

Place an HTML textbox into the form (it may be invisible):

<INPUT type="text" style="visibility:hidden"/>

If you press the enter key when the textbox has focus, form will submit and the button's click event will be executed.

If you have a single button in a form, the solution described above may be useful. However, for forms with more than one button, we need to specify exactly what button will be clicked when visitor presses the enter key.

Solution 1: Using a Custom Javascript Function


The method below describes the way to specify a default button to submit when the user hits the enter key in a textbox.

<script language="JavaScript">

function clickButton(e, buttonid)
{
      var evt = e ? e : window.event;
      var bt = document.getElementById(buttonid);
      
      if (bt)
      {
          if (evt.keyCode == 13)
          {
               bt.click(); 
               return false;
          }
     }
}
</script>

When you press a key, OnKeyPress event is fired on the client side. This calls a function (clickButton) to which we pass the default button's id. The function simulates a mouse click on the button.

In order to associate above JavaScript function with the textbox, place the following snippet to the code behind.

TextBox1.Attributes.Add("OnKeyPress", "return clickButton(event,'" + Button1.ClickID + "')");

The above code snippet generates the following HTML code:

<input name="TextBox1" type="text" id="TextBox1" onkeypress="return clickButton(event,'Button1')"  />

This causes Button1 to be clicked when the enter key is hit inside Textbox1.

Solution 2: Using the Built-in Javascript Function


You have to place the clickButton JavaScript function in every web page for the method described in Solution 1 to work.

Place the following snippet to the code behind:

TextBox1.Attributes.Add("OnKeyPress", "javascript:if (event.keyCode == 13) __doPostBack('" + Button1.UniqueID + "','')");

The code snippet given above, renders an extra attribute for Textbox1 that checks for a key press and if it's the enter key, it fires ASP.NET's __doPostBack method with the unique id of the default button that virtually presses it.

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5