Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

Archive for July, 2008

ZoomIt v2.10

Posted by ken zheng on July 25, 2008

A fanatistic tool for presentation, check it out

http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx

Posted in Tools | Leave a Comment »

MicroSoft Australia Tech.ED 2008 Sessions

Posted by ken zheng on July 23, 2008

The session list is out for MicroSoft Australia Tech.ED 2008 Sessions, check it out to see which sessions are interesting to you.

https://aunz.msteched.com/au/public/sessions.aspx

Posted in Uncategorized | Tagged: | Leave a Comment »

Embedded Multiple Silverlight User Controls

Posted by ken zheng on July 23, 2008

Silverlight does not have the Page type, the term is currently used is RootVisual UserControl. RootVisual object is analogous to the root window in WPF and can only be set once for the lifetime of the app, and is effective once the Application’s Startup event is raised. But this not true, you can set RootVisual as many times you want. So Application_Startup can be used to call multiple Silverlight controls.

Create a Silverlight application in visual studio 2008
Add 3 new Silverlight controls and lets name them Header, Footer and Leftbar.
Now put some text in these controls so that they can be distinguished on the aspx page.

Call these control s in the Form of Testpageforsilverlightapplication and set the InitParameters.

Change the Application_Startup in App.xaml.cs as below.

private void Application_Startup(object sender, StartupEventArgs e)

{

if (e.InitParams.ContainsKey(“ControlId”))

{

switch (e.InitParams["ControlId"])

{

case “Header”:

this.RootVisual = new Header();

break;

case “Leftbar”:

this.RootVisual = new Leftbar();

break;

case “Footer”:

this.RootVisual = new Footer();

break;

}

}

}

Run the application and all the 3 controls can be seen on aspx page. If we put a breakpoint at Application_Startup and we can see that it is called as many times as there silverlight controls on aspx page.

Posted in Silverlight | Tagged: | Leave a Comment »

Turn off region collapsing in vb.net

Posted by ken zheng on July 11, 2008

I am working on a client who is using vb .net and love regions. So to turn all the region off ctrl+M+M will only turn one off.

My Readify fellow give me a Macro which I think someone may have interest on:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module Module1
    Sub ExpandAllRegions()
        Dim objSelection As TextSelection ' Our selection object
        DTE.SuppressUI = True ' Disable UI while we do this
        objSelection = DTE.ActiveDocument.Selection() ' Hook up to the ActiveDocument's selection
        objSelection.StartOfDocument() ' Shoot to the start of the document

        ' Loop through the document finding all instances of #region. This action has the side benefit
        ' of actually zooming us to the text in question when it is found and ALSO expanding it since it
        ' is an outline.
        Do While objSelection.FindText("#region", vsFindOptions.vsFindOptionsMatchInHiddenText)
            ' This next command would be what we would normally do *IF* the find operation didn't do it for us.
            'DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
        Loop
        objSelection.StartOfDocument() ' Shoot us back to the start of the document
        DTE.SuppressUI = False ' Reenable the UI
        objSelection = Nothing ' Release our object
    End Sub

    ' Collapses all regions in the current document
    Sub CollapseAllRegions()
        Dim objSelection As TextSelection ' Our selection object
        ExpandAllRegions() ' Force the expansion of all regions
        DTE.SuppressUI = True ' Disable UI while we do this
        objSelection = DTE.ActiveDocument.Selection() ' Hook up to the ActiveDocument's selection
        objSelection.EndOfDocument() ' Shoot to the end of the document
        ' Find the first occurence of #region from the end of the document to the start of the document. Note:
        ' Note: Once a #region is "collapsed" .FindText only sees it's "textual descriptor" unless
        ' vsFindOptions.vsFindOptionsMatchInHiddenText is specified. So when a #region "My Class" is collapsed,
        ' .FindText would subsequently see the text 'My Class' instead of '#region "My Class"' for the subsequent
        ' passes and skip any regions already collapsed.
        Do While (objSelection.FindText("#region", vsFindOptions.vsFindOptionsBackwards))
            DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") ' Collapse this #region
            objSelection.EndOfDocument() ' Shoot back to the end of the document for
            ' another pass.
        Loop

        objSelection.StartOfDocument() ' All done, head back to the start of the doc
        DTE.SuppressUI = False ' Reenable the UI
        objSelection = Nothing ' Release our object
    End Sub

End Module

Posted in .Net, VS2008 | Tagged: | Leave a Comment »

Expression Blend Tutorial

Posted by ken zheng on July 9, 2008

Today I have found very good tutorials for Expression Blend from www.movielibrary.lynda.com. These tutorials covers the topics like
Overview and Installation, The Workspace, Managing Your Projects, Drawing in Blend, Appearance, Working with Text, Using 3D, Media Integration, Layout Controls, Media Integration, Layout Controls, Transformations, Animation and Interactivity, WPF Controls, Working with Data, Application Deployment, Please find following Expression Blend tutorial pages
Expression Blend
Getting Started with Expression Blend 3.75 hours

Expression Blend Beta Preview 2.5 hours

Expression Design
Getting Started with Expression Design

Hope these tutorials are useful. Suggest the some more best tutorials on this topic in bellow comment section.

Posted in Uncategorized | Tagged: , | Leave a Comment »

Two rows of tab headers in TabContainer in Ajax Control Toolkit

Posted by ken zheng on July 9, 2008

I actually found the answer but it took a lot of digging on the net. It’s from Nazar Rizvi’s blog

http://www.narizvi.com/blog/post/Two-rows-of-tab-headers-in-TabContainer-in-Ajax-Control-Toolkit.aspx

You have to go into the Tab.css and change the “.ajax__tab_default .ajax__tab_header {}” line. Then the Tab headers will wrap.

If you don’t wan to re-compile the code, just do

tag at the top:
!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”;>

then:
style type=”text/css”
.ajax__tab_xp .ajax__tab_header {white-space:normal;}
/style>

and:

ajaxToolkit:TabContainer runat=”server” ID=”GIListTabs” Width=”100%” CssClass=”ajax__tab_xp”

Posted in Uncategorized | Tagged: , | 1 Comment »

Validator and AJAX Tab

Posted by ken zheng on July 3, 2008

In this example, I use AJAX Tab and has RequiredFieldValidator in eacy tab. The challenge is I need to tell which validator is invalid and the container Tab is selected.
The parameter 0 is the RequiredFieldValidator , 1 is the tab control and 2 is the index

String js = string.Format(“if(document.getElementById(‘{0}’).isvalid ==false)$get(‘{1}’).control.set_activeTabIndex({2})”,cvlCategories.ClientID, tbcItemDetails.ClientID,1);
btnSave.Attributes.Add(“OnClick”, js);

Posted in VS2008 | 1 Comment »

How do I post source code

Posted by ken zheng on July 2, 2008

sourcecode language=’css’]…[/sourcecode

Do not copy and paste this code – write it out (it’s not that long! You can replace the language with “css” with the language that you’re writing in. Currently we support syntax highlighting for the following language codes:

cpp
csharp
css
delphi
html
java
jscript
php
python
ruby
sql
vb
xml

Posted in Uncategorized | Leave a Comment »

See if page is valid from JavaScript

Posted by ken zheng on July 2, 2008

I did a little digging through the javascript code that ASP.Net uses to do its client-side (javascript) validation to figure out how ASP.Net knows if the page or group is valid or not before submitting the form. Here is the hack you can use to do it yourself.

// a empty string means page.
var validationGroupName = "";

if (typeof(Page_ClientValidate) == 'function')
{
var validationResult = Page_ClientValidate(validationGroupName);

if (validationResult == true)
{
// do your cool javascript stuff here. This will only happen if the page or group is valid
}
}

Posted in Uncategorized | Tagged: | 1 Comment »