Archive for March, 2009

How to Test XAML

XAML is acronym for eXtensible Application Markup Language (and pronounced “Zammel”) and it is used for developing Silverlight Application. XAML can be written using any text editor like Notepad++, EditPlus or Simply Notepad, but after writing XAML there is a need to check whether XAML is working properly or not. There are tools available for running XAML application including Visual Studio or Microsoft Expression Blend. But there are some other ways also that can be used to run and test you XAML Application

SilverlightPad

SilverlightPad is a community application available at Silverlight community website. SilverlightPad can be used online as well as offline. If you are running SilverlightPad online then you can see XAML files on the left hand side. JavaScript tab is also there for attaching JavaScript with XAML. The XAML markup you type is parsed when you click on the Parse button on the bottom right, and the corresponding UI is rendered in the Scene pane.

SilverlightPad can only be used for testing Silverlight 1.0 applications.

Visit SilverlightPad Website

KaXAML

KaXAML is a windows application and it can be used to test Silverlight 2.0 applications also. On the right hand side KaXAML has a XAML pane where you can put or type XAML code. LaXAML also has a small toolbar comes very handy for taking snapshots, filling colors and performing some basic tasks.

KaXAML

Retrieving Page Controls Programmatically

There might be situations where you want to retrieve controls that are present in a web page and process them. In that case this article can be very use. Basically a web page is a container for all controls and for retrieving all controls we need to traverse the control tree. So for this this program can be used to disable all form controls at runtime

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        disableControls(Me.Page)


    End Sub
    Public Sub disableControls(ByVal controltree As Control)
        For Each tempcontrol As Control In controltree.Controls
            If TypeOf tempcontrol Is TextBox Then
                CType(tempcontrol, TextBox).Enabled = False
                Continue For
            ElseIf TypeOf tempcontrol Is Label Then
                CType(tempcontrol, Label).Enabled = False
                Continue For
            ElseIf TypeOf tempcontrol Is Button Then
                CType(tempcontrol, Button).Enabled = False
                Continue For
            ElseIf tempcontrol.Controls.Count > 0 Then
                disableControls(tempcontrol)
            End If
        Next
    End Sub
End Class

Before using this code there are some performance issues

  • If you are calling this function from different pages and then storing the state of page is very useful for example if you already disabled all the controls then there is no need to pass the page control to this method This can be easily done with storing the page state in session variable.

ASP.net Special Folder

To have a convenient folder and file structure help web developers and designers to manage their web application in a efficient manner. With the release of .Net Framework 2.0, ASP.net reserves the some folder names, so developers can put special files in these folders.

App_Browser 

ASP.net reserve this folder name for storing browser definition files. Browser definition files are used to determine the client browser capabilities. Browser definition files have .browser extension.

App_Code

App_code folder can contain source code for utility classes as well business objects. Classes that are present in App_Code folder are automatically complied when your web application complied. Arbitrary file types can be placed in the App_Code folder to create strongly typed objects. For example, placing Web service files (.wsdl and .xsd files) in the App_Code folder creates strongly typed proxies. Code present in App_Code is automatically referenced by ASP.net Application.

App_Data

App_Data is used to store file that can be used as database files including MDF files, XML files, as well as other data store files. App_Data folder is used by ASP.net application for storing ASP.net application local database. Developers can also use this folder for storing data for their ASP.net Application.

App_GlobalResources

App_GlobalResources folder contains resources files that are complied into assemblies and these assemblies are available in Global scope. Resource files are strongly typed and can be accessed programmatically.

App_LocalResources

App_LocalResources folder also contain the same files that are being contained by App_GlobalResources  but files located in this folder are only available to a particular project, web page, master page or web user control.

App_Themes

App_Themes folder used by ASP.net to store files that are being used to define the look and feel of web application. App_Themes folder store skin, CSS and image files. Skin files are files have .skin file extension.

Bin

Bin folder contains complied assemblies(.dll) files for web user controls, classes or for components.

Technorati Tags: , , , , , ,

How to Change Visual Studio Default DocType

Visual Studio 2008 When you create web pages in Visual Studio 2008, they are by default XHTML 1.0 Transitional. Sometimes developer want more control over the DocType or they want their pages to be XHTML 1.0 compliance. So you can also change the DocType or if you are using master pages then changing DocType is very easy just change the DocType in master page and all the child pages that use the master page will automatically acquire the DocType.

It is also possible to change the Visual Studio default page template also. To do this you first need to change the visual studio default page template and then build the visual studio template cache.

  • First you need to modify the visual studio template file. You can find the visual studio template file path “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\Web\VisualBasic\1033\WebForm.zip”.
  • Unzip the webform.zip and modify these two file “WebForm.aspx and WebForm_cb.aspx”.
  • Simply change the DocType.
  • After updating the visual studio template files, delete the                            c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache folder to clear out the template cache.
  • Run Visual Studio using the following command line to rebuild the template cache:
    devenv /InstallVSTemplates

Technorati Tags: , ,

How to Load User Control Programmatically

Web User ControlSometimes it may happen that you need a functionality is not  provided by built in ASP.net controls at that time developers can create ASP.net user controls or ASP.net custom controls.

  • User controls. User controls are containers into which you can put markup and Web server controls. You can then treat the user control as a unit and define properties and methods for it.
  • Custom controls. A custom control is a class that you write that derives from Control or WebControl.

Read the rest of this entry »