Archive

Archive for March, 2010

Kerala Google Technology User Group (GTUG) – Launch event on 10th April 2010

March 31st, 2010 Anuraj P No comments

Kerala Google Technology User Group (GTUG) – Launch event on 10th April 2010

Kerala Google Technology User Group (GTUG)

Kerala Google Technology User Group (GTUG)

Venue

UST Global
6th Floor (Zentith Hall) ,Bhavani,Technopark
Trivandrum-695581, Kerala

Date / Time: 10 AM to 4 PM

For more details check out :Kerala GTUG Website

Using custom controls from App_Code folder

March 30th, 2010 Anuraj P No comments

If you are developing a web application, and when are trying to add a Class File to the project Visual Studio will ask a confirmation like “You are attempting to add a special file type (class) to an ASP.NET Web site. In general, to use this type of item in your site, you should place it in the ‘App_Code’ folder. Do you want to place the file in the ‘App_Code’ folder?” – If you say yes, it will create(if not exists) an App_Code folder and place the class file in this folder. The App_Code is an ASP.Net special folder introduced in ASP.Net 2.0 onwards, it acts as the BIN folder, where you can store source files, which will be compiled in runtime. You can find more details about App_Code folder in MSDN : Shared Code Folders in ASP.NET Web Sites.

Few days back I created a custom contol in App_Code folder, and I couldn’t found any way to add in my aspx page. After doing some search I found two ways to do it.

  1. Directly specifying App_code folder in ASPX Page.
  2. <%@ Register TagPrefix="dotnetthoughts" Assembly="__Code" Namespace="dotnetthoughts.Controls" %>
    

    In this Assembly attribute specifies the control is from App_Code folder. And the Namespace specifies the Control name space.(By default when you are adding a Class file namespace won’t be there, you need to add a Namespace.)

  3. Registering the Control to application via Web.Config.
  4. <configuration>
            <system.web>
                    <pages>
                            <controls>
                                    <add namespace="dotnetthoughts.Controls" tagPrefix="dotnetthoughts"/>
                            </controls>
                    </pages>
            </system.web>
    </configuration>
    

    In this you don’t need to specify the control is loading from App_Code folder. Hopes it will be useful.

Developing simple Windows 7 Gadget – Part 3

March 9th, 2010 Anuraj P No comments

In this I am exploring another two features of Gadget API, one is Docking and other is Flyout. The Docking feature is helpful in Windows Vista, because the gadget lives only in Vista Sidebar, but in Windows 7 it can be anywhere in the desktop. The Docking feature helps to change the size of Gadget, in Windows Vista, the docking / un-docking events will automatically fired, when we drag the gadget out of the sidebar, but in Windows 7 another button will displayed in the Gadget toolbox. You can query the current state of a gadget with System.Gadget.docked. It returns true if docked, false if undocked.

Docking / UnDocking button in Sidebar

Docking / UnDocking button in Sidebar

There are also two events that you can monitor, System.Gadget.onDock and System.Gadget.onUndock, to determine when the docking state changes.

You can change the Width of the gadget by calling document.body.style.width = “130px”;. And the Docking and Undocking events should be attached on the Page_load.

System.Gadget.onDock = dockStateChanged;
System.Gadget.onUndock = dockStateChanged;

And the dockStateChanged function is

function dockStateChanged() {
//Checks the current state of the Gadget, if Docked state, setting the width to 130px;
//Otherwise changing to 330px;
	if (System.Gadget.docked) {
		document.body.style.width = "130px";
document.getElementById("RSSOutput").style.width = "125px";
	} else {
		document.body.style.width = "330px";
document.getElementById("RSSOutput").style.width = "325px";
	}
}

Another feature is Flyout. Flyouts used to extend the Gadget UI. The flyouts are system modal—only one can be displayed at a time. And when a gadget loses focus, its flyout will close. API for Flyouts available under System.Gadget.Flyout. As the flyouts is completely a separate window, with its own DOM, helps to add / create controls dynamically in it. Also you need to specify the flyout file, like Settings file.

The System.Gadget.Flyout.document returns the Document object of the flyout window. To display a flyout you need to set Flyout.show to True and to hide, set it to false. This property also returns the current state of flyout. But we cannot control the location of side bar, it is managed by Sidebar or OS.

System.Gadget.Flyout.file = "flyout.html";

There are certain events also available for Flyouts

System.Gadget.Flyout.onShow = function()
{
//Do something, when flyout is opening, may be a dynamic control creation
}
System.Gadget.Flyout.onHide = function()
{
//Do some code.
}