• About Ken
  • Ken’s CV

All About SharePoint

~ Liedong(Ken) Zheng, Independent SharePoint Consultant

All About SharePoint

Monthly Archives: June 2008

CheckBox and CheckBoxList Validators for multiple checkboxlists

27 Friday Jun 2008

Posted by ken zheng in .Net, VS2008

≈ 1 Comment

Tags

CheckBoxList Validator, JavaScript

Use 4Guys Creating CheckBox and CheckBoxList Validators in ASP.NET 2.0, you can build a custom validator control for your Checkbox and checkboxlist. But if you have more than one CheckBoxList in your page, the validator will not work because the Javascript will only apply to one control.

What you can do is modify the validator class to create an individual javascript for each validator.

In GenerateClientValidation method

change to:

….

Attributes["evaluationfunction"] = "VerifyItemSelected_" + <strong>ControlToValidate</strong>;

StringBuilder scriptBuilder = new StringBuilder();

scriptBuilder.Append(@"&lt;script language='javascript'&gt;");
scriptBuilder.Append(string.Format("function VerifyItemSelected_{0}", <strong>ControlToValidate</strong>));
scriptBuilder.Append(@"() {");
scriptBuilder.Append(string.Format("var targetControlName = document.getElementById('{0}')", this.ClientID));
scriptBuilder.Append(@".controltovalidate;");

…..

Finally,

Page.ClientScript.RegisterClientScriptBlock(typeof(CheckBoxListValidator), “CustomCheckboxListValidationScript_” + ControlToValidate, scriptBuilder.ToString());

By changing the code, we can ensure all the validator scripts are being registered.

Advertisements

CSS Inheritance

26 Thursday Jun 2008

Posted by ken zheng in .Net

≈ 1 Comment

Tags

CSS

we can assign multiple class names to a single element? That means we can change the style sheet so it looks like this:

.boxOut {
  width: 12em;
  padding: 0.5em;
  margin: 0.5em;
  border: solid 1px black;
}

.oddBoxOut {
  float: left;
}

.evenBoxOut {
  float: right;
}

And then the HTML will look like:

<div class="boxOut oddBoxOut">

Grouping Selectors

A single style may have multiple selectors assigned to it through the use of grouping.

To revisit the previous example, we first simplify the HTML so we only mention the one class:

<div class="oddBoxOut">

Then we assign the CSS we want to it, but we group the common property/value pairs.

.oddBoxOut, 
.evenBoxOut {
  width: 12em;
  padding: 0.5em;
  margin: 0.5em;
  border: solid 1px black;
}

.oddBoxOut {
  float: left;
}

.evenBoxOut {
  float: right;
}

These two techniques should solve most problems which people think can be solved with OO-style inheritance

ListView ItemTemplate and AlternatingItemTemplate

25 Wednesday Jun 2008

Posted by ken zheng in .Net, VS2008

≈ 2 Comments

Tags

Listview

The ASP.NET 3.5 ListView server control provides an ItemTemplate and an AlternatingItemTemplate.  Only the ItemTemplate is required for defining each row’s content.  The AlternatingItemTemplate can be used to define row content for odd numbered rows, however quite often the even and odd rows are identical with the exception that a different CSS class definition needs to be used, so to provide a different visible experience to the user.  Rather than duplicate the bulk of the ItemTemplate into the AlternatingItemTemplate, one can provide inline code to examine the container’s row number and return a specific even or odd CSS class name, illustrated as follows:

   1:  <asp:ListView ID="listViewSort" 
   2:      DataSourceID="ObjMenu"
   3:      DataKeyNames="Name"
   4:      runat="server">
   5:      <LayoutTemplate>
   6:          <table runat="server"
   7:              class="listViewGrid"
   8:              cellspacing="0"
   9:              border="0">
  10:  
  11:              <tr runat="server" id="itemPlaceholder" />
  12:  
  13:          </table>    
  14:      </LayoutTemplate>
  15:      <ItemTemplate>
  16:          <tr class="<%# ((ListViewDataItem)Container).DisplayIndex % 2 == 0 ? "itemRow" : "altItemRow" %>">
  17:              <td align="left" style="width: 200px;">
  18:                  <asp:Label runat="server"
  19:                      Text=’<%# Eval("Name") %>’ />
  20:              </td>
  21:              <td align="right" style="width: 100px;">   
  22:                  <asp:Label runat="server"
  23:                      Text=’<%# Eval("Price") %>’ />
  24:              </td>
  25:              <td align="left" style="width: 400px;">
  26:                  <asp:Label runat="server"
  27:                      Text=’<%# Eval("Description") %>’ />
  28:              </td>
  29:              <td align="right" style="width: 100px;">
  30:                  <asp:Label runat="server"
  31:                      Text=’<%# Eval("Calories") %>’ />
  32:              </td>
  33:          </tr>
  34:      </ItemTemplate>
  35:  </asp:ListView>

 

 

If the inline processing is more complicated than one would prefer for inline code, then one can invoke a protected web page method to accomplish similar or more complicated tasks, illustrated as follows:

   1:  <asp:ListView ID="listViewSort" 
   2:      DataSourceID="ObjMenu"
   3:      DataKeyNames="Name"
   4:      runat="server">
   5:      <LayoutTemplate>
   6:          <table runat="server"
   7:              class="listViewGrid"
   8:              cellspacing="0"
   9:              border="0">
  10:  
  11:              <tr runat="server" id="itemPlaceholder" />
  12:  
  13:          </table>
  14:      </LayoutTemplate>
  15:      <ItemTemplate>
  16:          <tr class="<%# GetCssName(Container) %>">
  17:              <td align="left" style="width: 200px;">
  18:                  <asp:Label runat="server"
  19:                      Text=’<%# Eval("Name") %>’ />
  20:              </td>
  21:              <td align="right" style="width: 100px;">   
  22:                  <asp:Label runat="server"
  23:                      Text=’<%# Eval("Price") %>’ />
  24:              </td>
  25:              <td align="left" style="width: 400px;">
  26:                  <asp:Label runat="server"
  27:                      Text=’<%# Eval("Description") %>’ />
  28:              </td>
  29:              <td align="right" style="width: 100px;">
  30:                  <asp:Label runat="server"
  31:                      Text=’<%# Eval("Calories") %>’ />
  32:              </td>
  33:          </tr>
  34:      </ItemTemplate>
  35:  </asp:ListView>

 

The protected web page method in turn can provide simple or more complex logic.  In this illustration, the same logic is provided as the inline code example:

   1:  protected string GetCssName(object container)
   2:  {
   3:      if (container != null)
   4:      {
   5:          if (container.GetType() == typeof(ListViewDataItem))
   6:          {
   7:              if ((((ListViewDataItem)container).DisplayIndex % 2) == 0)
   8:              {
   9:                  return "itemRow";
  10:              }
  11:              else
  12:              {
  13:                  return "altItemRow";
  14:              }
  15:          }
  16:      }
  17:      return null;
  18:  }

 

 

While the ListView server control AlternatingItemTemplate is quite useful, its use should be limited to instances where there is truly differing content requirements between even and odd numbered rows.  The above illustrations also works equally as well with my previously posted ListViewSort custom control.

CSS Stylizer

25 Wednesday Jun 2008

Posted by ken zheng in Uncategorized

≈ 1 Comment

Tags

CSS

Been playing with this http://www.skybound.ca/stylizer/ CSS editor lately, and it has some really nice features:

It has a drop down to indicate only certain style elements appear in certain browser flavours:

That’s pretty cool. I just use a bookmark for that at the moment (http://www.noupe.com/better-design/7-css-hacks-you-cannt-live-without.html) but IDE integration would rock.

SharePointDeveloper

23 Monday Jun 2008

Posted by ken zheng in Sharepoint

≈ Leave a comment

Tags

Sharepoint

New Sharepoint development resource site

http://www.microsoft.com/click/SharePointDeveloper/

Configuring CRM wrt application integration

22 Sunday Jun 2008

Posted by ken zheng in CRM

≈ Leave a comment

Configuring CRM wrt application integration is a nightmare, but you can find some useful tools to work with.

Here’s a set of sample data:

http://www.microsoft.com/downloads/details.aspx?FamilyId=D5F77EE7-3D01-4944-B5DC-C8CDC8123DF4&displaylang=en

And there’s also a tool for generating test data, and lets you save your data out of CRM back into an xml packet for later reuse:

(crm demonstration tools:)

http://www.microsoft.com/downloads/details.aspx?familyid=634508DC-1762-40D6-B745-B3BDE05D7012&displaylang=en

CRM 4 unauthorized web access

20 Friday Jun 2008

Posted by ken zheng in CRM

≈ Leave a comment

Tags

CRM 4.0

calls CRM’s web services  we always get error “The request failed with HTTP status 401: Unauthorized.”

The reason is CRM 4.0 was being used, and multi-instancing is a problem. You need to provide an auth token that specifies by customer name which instance you intend to use.

http://msdn.microsoft.com/en-us/library/cc151052.aspx

Wireless Networking: Windows Vista VPN Setup

18 Wednesday Jun 2008

Posted by ken zheng in Handy Tips

≈ 1 Comment

hese instructions explain how to set up a Virtual Private Network (VPN) in Windows Vista.

Click on the Start icon and select Control Panel

Click Network and Internet and select Network and Sharing Center

From within Network and Sharing Center select Set up a connection or network on the left side of the screen

Scroll down and select Connect to a workplace and click Next

Select Use my Internet connection (VPN)

Select I’ll set up an Internet connection later

Enter vpn.glos.local in the Internet address: box and click Next

Enter your University username and password and click Create

The screen below should then appear.  Click Close

In this Section…

Wireless

Wireless Networking – Windows Vista Setup

Wireless Networking – Windows Vista VPN Setup

Wireless Networking – Connecting with Windows Vista

Wireless Networking – XP Setup

Wireless Networking – VPN Setup

Wireless FAQ’s

Use LET keyword in LINQ

13 Friday Jun 2008

Posted by ken zheng in LINQ

≈ Leave a comment

Tags

let, LINQ

As Luke Hoban explains on his blog:

With let query clauses, you can introduce a variable into scope and use it in the subsequent query clauses. Similar to local variables in a method body, this gives you a way to avoid evaluating a common expression multiple times by storing it in a variable. This can be very useful even in much simpler queries. Of course, in the query above – let is absolutely critical.

The “query above” he refers to is a ray tracer coded as a big LINQ query full of let clauses!

Let’s see is an example from the official LINQ forum.
Someone asked how to query the following XML document:

<cars>
<car name="Toyota Coupe">
<profile name="Vendor" value="Toyota"/>
<profile name="Model" value="Celica"/>
<profile name="Doors" value="2"/>
<support name="Racing" value="yes"/>
<support name="Towing" value="no"/>
</car>
<car name="Honda Accord Aerodec">
<profile name="Vendor" value="Honda"/>
<profile name="Model" value="Accord"/>
<profile name="Doors" value="4"/>
<support name="Racing" value="no"/>
<support name="Towing" value="yes"/>
</car>
</cars>

Here is one way to do it:

from car in root.Elements("car")
let profiles =
from profile in car.Elements("profile")
select new {
Name = profile.Attribute("name").Value,
Value = profile.Attribute("value").Value
}
let supports =
from support in car.Elements("support")
select new {
Name = support.Attribute("name").Value,
Value = support.Attribute("value").Value
}
select new Car {
Name = car.Attribute("name").Value,
Vendor = profiles.Single(prof => prof.Name == "Vendor").Value,
Model = profiles.Single(prof => prof.Name == "Model").Value,
Doors = int.Parse(profiles.Single(prof => prof.Name == "Doors").Value),
RacingSupport = supports.Single(sup => sup.Name == "Racing").Value == "yes"
};


It’s easier to isolate the “profile” and “support” elements in separate sequences using let clauses, as above. Then the select clause becomes simple to write.

Silverlight 2 Beta2 Released

09 Monday Jun 2008

Posted by ken zheng in Uncategorized

≈ Leave a comment

Tags

Silverlight

Silverlight 2 Beta2 was released today.  You can download both Silverlight 2 Beta2 and the Visual Studio and Expression Blend tools support to target it here.

Beta2 adds a lot of new features (more details below), but is still a 4.6 MB download that takes less than 10 seconds to install on a machine.  It does not require the .NET Framework or any other software to be installed for it to work, and all features work cross-browser on both Mac and Windows machines.  These features will also be supported on Linux via the Moonlight 2 release.

Silverlight 2 Beta2 supports a go-live license that allows you to start using and deploying Silverlight 2 for commercial applications. There will be some API changes between Beta2 and the final release, so you should expect that applications you write with Beta2 will need to make some updates when the final release comes out.  But we think that these changes will be straight-forward and relatively easy, and that you can begin planning and starting commercial projects now.

You can build Silverlight Beta2 applications using the VS 2008 Tools for Silverlight and Expression Blend 2.5 June Preview downloads.  You can download both of them here.  The VS 2008 Tools for Silverlight download works with both VS 2008 and the recent VS 2008 SP1 beta release.

← Older posts

Pages

  • About Ken
  • Ken’s CV

Blog Stats

  • 1,635,079 hits

.Net 3.5 5566 AJAX BCS BDC C# Calendar Content Type CSS Custom Page Document ID Fast Search favicon Feature IIS InfoPath infopath form JavaScipt JavaScript jQuery LINQ Listview Managed Property Master Page MCP MCPD migration MOQ MySite Page Layout PowerShell Proxy Search Search Scope SharePoiint 2010 SharePoiint 2010; Search SharePoin Sharepoint Sharepoint 2007 SharePoint2007 Sharepoint 2010 Sharepoint Search Silverlight Site Collection Site Definition Site Master Page site templates SPDisposeCheck SPD workflow SPSiteDataQuery SPUser SQL SSP stored procedure STSADM survey Tab TechEd Tech ED TSQL User Profile User Profiles Synchronization Service;SharePoint 2010 vs 2008 vs 2010 vs2010 WCF web.config webpart Web Part Web Service windbg workflow XML XSL XSLT

Archives

  • March 2016
  • April 2014
  • March 2014
  • February 2014
  • December 2013
  • October 2013
  • September 2013
  • March 2013
  • February 2013
  • August 2012
  • June 2012
  • May 2012
  • April 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008

Twitter Updates

  • @telstra @outage @3125 internet cable still not working since 8:30 am 6 months ago
  • @Telstra is internet cable service still down in Burwood Vic 3125? Have been issue for a day! 6 months ago
  • Anyone uses @Nintex Workflow for SharePoint online has email issue? all our external email actions are hanging since yesterday. 9 months ago
  • @Nintex Hi, is your Workflow External Email service is down? Since yesterday afternoon, no email being sent out usi… twitter.com/i/web/status/9… 9 months ago
  • @Nintex just wonder if there is any SharePoint online workflow server issue right now? All workflows are not reachable 1 year ago
Locations of visitors to this page

Blogroll

  • E-books Library
  • My Linkedin
  • SharePoint Community
  • SharePoint Developer Center
  • Silverlight Show
June 2008
M T W T F S S
« May   Jul »
 1
2345678
9101112131415
16171819202122
23242526272829
30  
Advertisements

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy