ASPHostDirectory Cheap .NET 4 Hosting

Blog about .NET Hosting and all its latest technology

ASPHostDirectory ASP.NET 4 Hosting :: URL Routing in ASP.NET 3.5 Webform

clock January 6, 2011 06:00 by author Darwin

URL Routing decouples the URL from a physical file on the disk, we can define routing rules to specify what URL maps to what physical files. ASP.NET Routing is not only for MVC and is independent library so ASP.NET Routing can be used in a traditional ASP.NET web forms.

First, add a reference to System.Web.Routing and make sure that web.config has UrlRoutingModule HTTP Module registered in httpModules section.

then, we create this class,

CustomRouteHandler.cs
//------------------------------------------------------
public class CustomRouteHandler : IRouteHandler
{
public CustomRouteHandler(string virtualPath)
{
this.VirtualPath = virtualPath;
}


public string VirtualPath { get; private set; }

public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
foreach (var paramUrl in requestContext.RouteData.Values)
{
requestContext.HttpContext.Items[paramUrl.Key] = paramUrl.Value;
}
var page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
}
//--------------------------------------------------
Then in Global.asax file and in Application_Start event, I will define my routing rules.

Global.asax
//----------------------------------------------
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}


private void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
routes.Clear();

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");

routes.Add("IndexPage", new Route("index/{page-num}", new CustomRouteHandler("~/Home/index.aspx")));
routes.Add("Index", new Route("index", new CustomRouteHandler("~/Home/index.aspx")));
routes.Add("ContactUs", new Route("contactus", new CustomRouteHandler("~/Home/contactus.aspx")));

}

The Route Data will be stored in HttpContext.Item (cache per request)
You can get the Route Data from HttpContext.Current.Items["name"] on the page.


What is so SPECIAL on ASPHostDirectory.com ASP.NET 4.0 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in ASP.NET 4.0 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory Silverlight 4 Hosting :: Export data to Excel from Silverlight/WPF DataGrid

clock December 23, 2010 09:45 by author Darwin

Data export from DataGrid to Excel is very common task, and it can be solved with different ways, and chosen way depend on kind of app which you are design. If you are developing app for enterprise, and it will be installed on several computes, then you can to advance a claim (system requirements) with which your app will be work for client. Or customer will advance system requirements on which your app should work. In this case you can use COM for export (use infrastructure of Excel or OpenOffice). This approach will give you much more flexibility and give you possibility to use all features of Excel app. About this approach I’ll speak below. Other way – your app is for personal use, it can be installed on any home computer, in this case it is not good to ask user to install MS Office or OpenOffice just for using your app. In this way you can use foreign tools for export, or export to xml/html format which MS Office can read (this approach used by JIRA). But in this case will be more difficult to satisfy user tasks, like create document with landscape rotation and with defined fields for printing.

Integration with Excel from Silverlight 4 and .NET 4

In Silverlight 4 and .NET 4 we have dynamic objects, which give us possibility to use MS Office COM objects without referenced to MS Office dlls. So for creating excel document in .NET 4 you can write this code::

dynamic excel = Microsoft.VisualBasic.Interaction.CreateObject("Excel.Application", string.Empty);

And in Silverlight 4 this:

dynamic excel = AutomationFactory.CreateObject("Excel.Application");

If you want to use AutomationFactory in Silverlight 4 app you need to set “Required elevated trust when running outside the browser” in project settings. You can check at code that your app have this privileges with property AutomationFactory.IsAvailable.

First, lets design new method, which will export to Excel two-dimension array:

public static void ExportToExcel(object[,] data) { /* ... */ }

Above I wrote how to get instance of Excel app. Now we will write some additional requirements for export:

excel.ScreenUpdating = false;
dynamic workbook = excel.workbooks;
workbook.Add(); 

dynamic worksheet = excel.ActiveSheet;

const int left = 1;
const int top = 1;
int height = data.GetLength(0);
int width = data.GetLength(1);
int bottom = top + height - 1;
int right = left + width - 1;

if (height == 0 || width == 0)
  return;

In this code we set that Excel will not show changes until we allow. This approach will give us little win in performance. Next we create new workbook and get active sheet of this book. And then get dimension of range where we will place our data.

Next step – export to Excel. When you export to excel with set data by cell this is slowly approach than export data to range of cells (you can try to compare speed of exporting with 1000 rows). So we will use setting data for range of cells:

dynamic rg = worksheet.Range[worksheet.Cells[top, left], worksheet.Cells[bottom, right]];
rg.Value = data;

Ok, our data in excel document. This approach work in .NET, but doesn’t work in Silverlight 4. When I tried to export data like I wrote above I got exception 

{System.Exception: can't convert an array of rank [2]
   at MS.Internal.ComAutomation.ManagedObjectMarshaler.MarshalArray(Array array, ComAutomationParamWrapService paramWrapService, ComAutomationInteropValue& value)
   at MS.Internal.ComAutomation.ManagedObjectMarshaler.MarshalObject(Object obj, ComAutomationParamWrapService paramWrapService, ComAutomationInteropValue& value, Boolean makeCopy)
   at MS.Internal.ComAutomation.ComAutomationObject.InvokeImpl(Boolean tryInvoke, String name, ComAutomationInvokeType invokeType, Object& returnValue, Object[] args)
   at MS.Internal.ComAutomation.ComAutomationObject.Invoke(String name, ComAutomationInvokeType invokeType, Object[] args)
   at System.Runtime.InteropServices.Automation.AutomationMetaObjectProvider.TrySetMember(SetMemberBinder binder, Object value)
   at System.Runtime.InteropServices.Automation.AutomationMetaObjectProviderBase.<.cctor>b__3(Object obj, SetMemberBinder binder, Object value)
   at CallSite.Target(Closure , CallSite , Object , Object[,] )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at ExportToExcelTools.ExportManager.ExportToExcel(Object[,] data)
   at ExportToExcelTools.DataGridExcelTools.StartExport(Object data)
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)}


For export in Silverlight I use this code (export by rows):

for (int i = 1; i <= height; i++)
{
  object[] row = new object[width];
  for (int j = 1; j <= width; j++)
  {
    row[j - 1] = data[i - 1, j - 1];
  }
  dynamic r = worksheet.Range[worksheet.Cells[i, left], worksheet.Cells[i, right]];
  r.Value = row;
  r = null;
}

If you are developing app just for Silverlight you can use some other data structure instead of array. I try to write code which will work at .NET and Silverlight so I will use arrays.

After data export we should to set to Excel object that it can apply changes, and then we will show it:

excel.ScreenUpdating = true;
excel.Visible = true;

Before this we can set more beautiful view of our document:

// Set borders
for (int i = 1; i <= 4; i++)
  rg.Borders[i].LineStyle = 1;

// Set auto columns width
rg.EntireColumn.AutoFit();

// Set header view
dynamic rgHeader = worksheet.Range[worksheet.Cells[top, left], worksheet.Cells[top, right]];
rgHeader.Font.Bold = true;
rgHeader.Interior.Color = 189 * (int)Math.Pow(16, 4) + 129 * (int)Math.Pow(16, 2) + 78; // #4E81BD

With this code we set borders, set auto size for cells and mark out first row (with background color and special style for text – it will be bold): it will be header, which will show DataGrid column’s headers. If you want to set more you can use Excel macros to get how to change document view: you need to start record macro, then change interface by hand, end record macro and look at macro code.

At the end of export you need to clean resources. In .NET for solve this you can use method Marshal.ReleaseComObject(…), but Silverlight doesn’t have this method, but we can set null to variables and then invoke garbage collector collect method:

#if SILVERLIGHT
#else
Marshal.ReleaseComObject(rg);
Marshal.ReleaseComObject(rgHeader);
Marshal.ReleaseComObject(worksheet);
Marshal.ReleaseComObject(workbook);
Marshal.ReleaseComObject(excel);
#endif
rg = null;
rgHeader = null;
worksheet = null;
workbook = null;
excel = null;
GC.Collect();

So know we have this code:

using System;
#if SILVERLIGHT
using System.Runtime.InteropServices.Automation;
#else
using System.Runtime.InteropServices;
#endif 

namespace ExportToExcelTools
{
  public static class ExportManager
  {
    public static void ExportToExcel(object[,] data)
    {
#if SILVERLIGHT
      dynamic excel = AutomationFactory.CreateObject("Excel.Application");
#else
      dynamic excel = Microsoft.VisualBasic.Interaction.CreateObject("Excel.Application", string.Empty);
#endif 

      excel.ScreenUpdating = false;
      dynamic workbook = excel.workbooks;
      workbook.Add(); 

      dynamic worksheet = excel.ActiveSheet; 

      const int left = 1;
      const int top = 1;
      int height = data.GetLength(0);
      int width = data.GetLength(1);
      int bottom = top + height - 1;
      int right = left + width - 1; 

      if (height == 0 || width == 0)
        return; 

      dynamic rg = worksheet.Range[worksheet.Cells[top, left], worksheet.Cells[bottom, right]];
#if SILVERLIGHT
      //With setting range value for recnagle export will be fast, but this aproach doesn't work in Silverlight
      for (int i = 1; i <= height; i++)
      {
        object[] row = new object[width];
        for (int j = 1; j <= width; j++)
        {
          row[j - 1] = data[i - 1, j - 1];
        }
        dynamic r = worksheet.Range[worksheet.Cells[i, left], worksheet.Cells[i, right]];
        r.Value = row;
        r = null;
      }
#else
      rg.Value = data;
#endif 

      // Set borders
      for (int i = 1; i <= 4; i++)
        rg.Borders[i].LineStyle = 1; 

      // Set auto columns width
      rg.EntireColumn.AutoFit(); 

      // Set header view
      dynamic rgHeader = worksheet.Range[worksheet.Cells[top, left], worksheet.Cells[top, right]];
      rgHeader.Font.Bold = true;
      rgHeader.Interior.Color = 189 * (int)Math.Pow(16, 4) + 129 * (int)Math.Pow(16, 2) + 78; // #4E81BD     

      // Show excel app
      excel.ScreenUpdating = true;
      excel.Visible = true;

#if SILVERLIGHT
#else
      Marshal.ReleaseComObject(rg);
      Marshal.ReleaseComObject(rgHeader);
      Marshal.ReleaseComObject(worksheet);
      Marshal.ReleaseComObject(workbook);
      Marshal.ReleaseComObject(excel);
#endif
      rg = null;
      rgHeader = null;
      worksheet = null;
      workbook = null;
      excel = null;
      GC.Collect();
    }
  }
}

Export data from DataGrid to two-dimension array

So we have method which export array to Excel, now we need to write method which will export DataGrid data to array. In WPF we can get all items with Items property, but in Silverlight this property is internal. But we can use ItemsSource property and cast it to List:

List<object> list = grid.ItemsSource.Cast<object>().ToList();

Before we realize export I want to think about features we need:

1. In some cases we want to export not all columns from data grid, so we need an approach to disable export some of columns.
2. In some cases columns don’t have header (text header), but in excel we want to see text header or header with other text than data grid have, so we need an approach to set header text for export.
3. It is easy to get which properties of object need to show in excel cell for columns with types inherited from DataGridBoundColumn because it has Binding with Path, with which we can get path for export value. But in case when we use DataGridTemplateColumn it is more hardly to find out which values of which property need to export. This is why we need an approach to set custom path for export (more we can use SortMemberPath).
4. We need to set formatting for export to Excel.


I solved all of this problems with attached properties:

/// <summary>
/// Include current column in export report to excel
/// </summary>
public static readonly DependencyProperty IsExportedProperty = DependencyProperty.RegisterAttached("IsExported",                                                                         typeof(bool), typeof(DataGrid), new PropertyMetadata(true));

/// <summary>
/// Use custom header for report
/// </summary>
public static readonly DependencyProperty HeaderForExportProperty = DependencyProperty.RegisterAttached("HeaderForExport",                                                                                typeof(string), typeof(DataGrid), new PropertyMetadata(null));

/// <summary>
/// Use custom path to get value for report
/// </summary>
public static readonly DependencyProperty PathForExportProperty = DependencyProperty.RegisterAttached("PathForExport",                                                                                typeof(string), typeof(DataGrid), new PropertyMetadata(null));

/// <summary>
/// Use custom path to get value for report
/// </summary>
public static readonly DependencyProperty FormatForExportProperty = DependencyProperty.RegisterAttached("FormatForExport",                                                                               typeof(string), typeof(DataGrid), new PropertyMetadata(null));

#region Attached properties helpers methods 
public static void SetIsExported(DataGridColumn element, Boolean value)
{
  element.SetValue(IsExportedProperty, value);


public static Boolean GetIsExported(DataGridColumn element)
{
  return (Boolean)element.GetValue(IsExportedProperty);


public static void SetPathForExport(DataGridColumn element, string value)
{
  element.SetValue(PathForExportProperty, value);


public static string GetPathForExport(DataGridColumn element)
{
  return (string)element.GetValue(PathForExportProperty);


public static void SetHeaderForExport(DataGridColumn element, string value)
{
  element.SetValue(HeaderForExportProperty, value);


public static string GetHeaderForExport(DataGridColumn element)
{
  return (string)element.GetValue(HeaderForExportProperty);


public static void SetFormatForExport(DataGridColumn element, string value)
{
  element.SetValue(FormatForExportProperty, value);


public static string GetFormatForExport(DataGridColumn element)
{
  return (string)element.GetValue(FormatForExportProperty);


#endregion

Then I use this code for getting all columns for export:

List<DataGridColumn> columns = grid.Columns.Where(x => (GetIsExported(x) && ((x is DataGridBoundColumn)
          || (!string.IsNullOrEmpty(GetPathForExport(x))) || (!string.IsNullOrEmpty(x.SortMemberPath))))).ToList();

With this code we get all columns with true values of IsExported attached property (I set true as default value for this attached property above) and for which I can get export path (binding or custom setting path, or SortMemberPath is not null).

Next we will create new two-dimension array, first dimension is number of elements plus one – for header. And then set text headers into first row of array:


// Create data array (using array for data export optimization)
object[,] data = new object[list.Count + 1, columns.Count]; 

// First row will be headers
for (int columnIndex = 0; columnIndex < columns.Count; columnIndex++)
  data[0, columnIndex] = GetHeader(columns[columnIndex]);

Method GetHeader try to get values from HeaderForExport attached property for current column and if it has null value method get header from column:

private static string GetHeader(DataGridColumn column)
{
  string headerForExport = GetHeaderForExport(column);
  if (headerForExport == null && column.Header != null)
    return column.Header.ToString();
  return headerForExport;
}

Then we fill array with values from DataGrid:

for (int columnIndex = 0; columnIndex < columns.Count; columnIndex++)
{
  DataGridColumn gridColumn = columns[columnIndex]; 

  string[] path = GetPath(gridColumn); 

  string formatForExport = GetFormatForExport(gridColumn); 

  if (path != null)
  {
    // Fill data with values
    for (int rowIndex = 1; rowIndex <= list.Count; rowIndex++)
    {
      object source = list[rowIndex - 1];
      data[rowIndex, columnIndex] = GetValue(path, source, formatForExport);
    }
  }
}

Method GetPath is easy, it try to get path from set by attached property value or binding or SortMemberPath. I only support easy paths: with only properties as chain of path, I don’t support arrays or static elements in paths, and of course I mean that binding set for current row item:

private static string[] GetPath(DataGridColumn gridColumn)
{
  string path = GetPathForExport(gridColumn); 

  if (string.IsNullOrEmpty(path))
  {
    if (gridColumn is DataGridBoundColumn)
    {
      Binding binding = ((DataGridBoundColumn)gridColumn).Binding as Binding;
      if (binding != null)
      {
        path = binding.Path.Path;
      }
    }
    else
    {
      path = gridColumn.SortMemberPath;
    }
 

  return string.IsNullOrEmpty(path) ? null : path.Split('.');
}

After getting path value with method GetValue we will try to get value by this path for current item:

private static object GetValue(string[] path, object obj, string formatForExport)
{
  foreach (string pathStep in path)
  {
    if (obj == null)
      return null; 

    Type type = obj.GetType();
    PropertyInfo property = type.GetProperty(pathStep); 

    if (property == null)
    {
      Debug.WriteLine(string.Format("Couldn't find property '{0}' in type '{1}'", pathStep, type.Name));
      return null;
   

    obj = property.GetValue(obj, null);
 

  if (!string.IsNullOrEmpty(formatForExport))
    return string.Format("{0:" + formatForExport + "}", obj); 

  return obj;
}

Sample

For sample I wrote some model classes and fill test data:

public class Person
{
  public string Name { get; set; }
  public string Surname { get; set; }
  public DateTime DateOfBirth { get; set; }


public class ExportToExcelViewModel
{
  public ObservableCollection<Person> Persons
  {
    get
    {
      ObservableCollection<Person> collection = new ObservableCollection<Person>();
      for (int i = 0; i < 100; i++)
        collection.Add(new Person()
        {
          Name = "Person Name " + i,
          Surname = "Person Surname " + i,
          DateOfBirth = DateTime.Now.AddDays(i)
        });
      return collection;
    }
  }
}

In WPF window I use this xaml declaration:

<Window x:Class="ExportToExcelSample.MainWindow"
        xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ExportToExcelSample="clr-namespace:ExportToExcelSample"
        xmlns:ExportToExcelTools="clr-namespace:ExportToExcelTools;assembly=ExportToExcelTools" >
    <Window.DataContext>
        <ExportToExcelSample:ExportToExcelViewModel />
    </Window.DataContext>
    <ScrollViewer>
        <StackPanel>
            <Button Click="Button_Click">Export To Excel</Button>
            <DataGrid x:Name="grid" ItemsSource="{Binding Persons}" AutoGenerateColumns="False" >
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=Name}" Header="Name" />
                    <DataGridTextColumn Binding="{Binding Path=Surname}" Header="Surname"                                        ExportToExcelTools:DataGridExcelTools.HeaderForExport="SecondName" />
                    <DataGridTemplateColumn ExportToExcelTools:DataGridExcelTools.FormatForExport="dd.MM.yyyy"                                            ExportToExcelTools:DataGridExcelTools.PathForExport="DateOfBirth"                                           ExportToExcelTools:DataGridExcelTools.HeaderForExport="Date Of Birth">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding
Path=DateOfBirth, StringFormat=dd.MM.yyyy}" />
                                    <TextBlock Text="{Binding
Path=DateOfBirth, StringFormat=HH:mm}" />
                                </StackPanel>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </StackPanel>
    </ScrollViewer>
</Window>

And method Button_Click with this code:

private void Button_Click(object sender, RoutedEventArgs e)
{
  grid.ExportToExcel();
}

Where ExportToExcel is extension method for DataGridm which invoke export to Excel method with separate thread. That's all. In Silverlight 4 code will be exactly the same. Below I’ll put anchor with samples for Silverlight 4 and WPF 4 (solution for Visual Studio 2010).

What is so SPECIAL on ASPHostDirectory.com Silverlight 4 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in
Silverlight Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory Visual Studio 2010 Hosting :: How to Solve Error CS0006, CS0009 in Visual Studio 2008

clock December 16, 2010 07:19 by author Darwin

Error Message:

CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found


How to Solve it?

1. check whether "System.EnterpriseServices.dll" file actually exists at that folder or not. You cannot navigate to the GAC_32 folder using windows explorer. You have to use command line to go there. From start menu, select 'Run' > type 'cmd' press enter. then directly go there:

cd C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

2. press enter. From here you have to copy the file to the desired location. Use this command:

copy System.EnterpriseServices.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

3. Now try to run that web project from visual studio, and it should work. If it doesnt work, and gives you another error: CS0009 compile error, then you have to copy all the files to that folder. First navigate to that source folder:

cd C:\Windows\Microsoft.NET\Framework\v2.0.50727

4. press enter. Then use this command to copy all DLLs:

copy *.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a

You dont need to overwrite any file that already exists at the destination folder. This should solve CS0009 error.


What is so SPECIAL on ASPHostDirectory.com Visual Studio 2010 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Visual Studio 2010 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory Silverlight 4 Hosting :: Silverlight 4 and MVVM pattern with ICommand

clock November 9, 2010 05:38 by author Darwin

MVVM (Model- View – View Model) is the WPF / Silverlight UI design Pattern code model. A certain guideline a developer should follows in order to achieve a more testable, debug gable, manageable, readable Application.

A zero code behind, yes no button click event hander in the code behind file, no form / windows load logic, no UI binding logic, No UI validation or type casting code in the code behind file. Yes i menn no code or logic in the UI mainpage.xaml.cs file.

Following features are used in order to achieve the MVVM pattern with no logic on the UI code behind file , and to make sure that the presentation layer and logic loosely couple.

1) Two way binding capability of WPF/Silverlight UI (XAML)
2) IValueConvert for binding (eg: string class converting to colour class)
3) INotification or Dependency Property
4) Data context
5) Static resources
6) Icommand for avoiding the code behind event handler.
7) Use of validation=true in xaml(presentation layer)


Before MVVM, the MVP pattern was famous for winform and wpf
applications ( Though it never took the full advantage of the Two way binding feature of WPF). MVC pattern is still famous with Asp.net Application.
Draw back of the old fashion winform or wpf / Silverlight application (with no mvvm pattern)


1) The Presentation and the code behind logic were tightly coupled
2) If we change the UI control we have change the logic in the code behind
3) Cannot imagine of more than one view sharing the same logic.
4) Not possible to write a unit test for a code behind, as the
presentation layer is tightly couple to the control.
5) In normal WPF application the view (xaml) is just treated as a data
storage.


Advantages of MVVM pattern:

1) Proper layering of the view and the data. The data is not stored in
view, View is just for presenting the data.
2) Clean testable and manageable code.
3) NO code behind so the Presentation layer and the logic are loosely
coupled.
4) With Silverlight 4.0 we have a new Icommand Support


In this example we have a textbox displaying Personname and another textbox displaying PersonAge,and on a click of a button the age will increment by a year till 26... the code is done in MVVM pattern.

Step 1: Create a Silverlight Application in Viual studio 2010 and name it as “simplePersonandageMVVM”

Step 2: Once created add a class file and call it as “PersonModel.cs” and paste this code . (this would be the model thats is data object)

using System.ComponentModel;

namespace simplePersonandageMVVM
{  

    public class PersonModel : InotifyPropertyChanged
    {
        string name;
        public string Name
        {
            get { return this.name; }
            set
            {
                this.name = value;
                fire("Name");

            }
        }
        int age;
        public int Age
        {
            get { return this.age; }
            set
            {
                this.age = value;
                fire("Age");
            }
        }
        public PersonModel() { }
        public PersonModel(string name, int age)
        {
            this.name = name;
            this.age = age;
        }

        public void fire(string x)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(x));
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }

}

Step 3: Create another class call it as “PersonViewModel.cs” This would be the viewModel and will take the role of an adapter between view(presentation layer) and the Model(entity class).

namespace simplePersonandageMVVM
{
    public class PersonViewModel
    {
        public PersonModel p { get; set; }
        public PersonViewModel()
        {
            p = new PersonModel("prabjot", 20);                    
        }

        public ICommand GetPerson
        {
            get { return new GetPersonCommand(this); }
        }       

        public void Increaseage(PersonModel d)
        {
            d.Age++;         
            string x = d.Age.ToString();          
            MessageBox.Show(x);               

        }
    }
}

Step 4: Create a Command object class implementing the ICOMMAND interface and call it as “GetPersonCommand.cs”. This class overrides both the Icommand methods. Here the method CanExecute() checks for the condition if its met then only the button click is enable. Where as the other method Execute() takes care of execution on button click.

namespace simplePersonandageMVVM
{
    public class GetPersonCommand : Icommand
    {
        PersonViewModel pincommand;
        public GetPersonCommand( PersonViewModel Pcame)
        {
          pincommand= Pcame;          

          
        }

        public bool CanExecute(object parameter)
        {
           if(pincommand.p.Age > 25)
           {
               return false ;
           }
        else
           {
               return true;
           }           

        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
           pincommand.Increaseage(pincommand.p);
        }
    }
}

Step 5: Finally your xaml file looks like this

<UserControl x:Class="simplePersonandageMVVM.MainPage"
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
             xmlns:local="clr-namespace:simplePersonandageMVVM"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <local:PersonViewModel  x:Key="pkey" />
    </UserControl.Resources>   

    <Grid x:Name="LayoutRoot" Background="White"
          DataContext="{Binding Source={StaticResource pkey}}" >
        <Grid Name="hi" DataContext="{Binding Path=p, Mode=TwoWay}">
            <TextBox Height="23" HorizontalAlignment="Left" Margin="53,30,0,0"
                 Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Path=Name, Mode=TwoWay}" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="53,68,0,0" Name="textBox2"
                 Text="{Binding Path=Age, Mode=TwoWay}"  VerticalAlignment="Top" Width="120" />
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="53,112,0,0" Name="button1"
                VerticalAlignment="Top" Width="75"  Command="{Binding Path=DataContext.GetPerson, ElementName= LayoutRoot }"
                    CommandParameter="{Binding Path=Age, ElementName=hi}"  />
      </Grid>
    </Grid>     

</UserControl>

What is so SPECIAL on ASPHostDirectory.com Silverlight 4 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Silverlight Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service
- We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration
- With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory Crystal Report 2008 Hosting :: Features in Crystal Report 2008

clock August 25, 2010 12:18 by author Darwin

Features in Crystal Report 2008:

1. Advanced Information Visualization with Flash, Flex and Xcelsius1

- Adobe Flash integration: A wide variety of flexible data presentation options are now available through Flash. Flash (SWF) files can be integrated into your report and report data can be shared with SWF via Flashvars for compelling, interactive, and information-rich reports. The SWF files can be embedded in the report or linked via a website.
1 Flash features are available for viewing in the .NET, Winform and Java DHTML viewers only

- Xcelsius integration: Import Xcelsius-generated SWF files into your report and benefit from improved design-time integration and stunning visualizations. Enhance your reports with what-if analysis models that enable users to make important decisions dynamically, without leaving the report file.

- Adobe Flex integration: Integrate your reports with operational workflows by embedding Adobe Flex (SWF) applications into your reports. Using Adobe Flex Builder you can create any business-user UI to access report data and integrate with external web services. Data in your report can be passed to the Flex application via Flashvars, making it easy to create a flexible UI even when you don’t have access to your data via web services. The Flex applications can do tasks like database write-back – invoking operational workflows directly within Crystal Reports.

2. Improved End-User Report Viewing Experience

- Interactive report viewing: On-report sorting, filtering, and report reformatting with the .NET Winform, Java DHTML, and .NET Webform viewers allows users to explore information interactively without re-querying the database. New optional parameters provide for complex user-driven filtering scenarios. Users can answer more business questions with fewer, more flexible reports – significantly reducing Developer and IT support dependency.

- Parameter panel: The report designer and the .NET Winform, Java DHTML, and .NET Webform viewers have a parameter panel so that parameter values can be set without refreshing data. Parameters used are displayed on the panel so that report consumers can easily see them, make changes, and have the new values applied directly to the saved data.

- Flexible pagination: Report designers can customize page size and easily control page breaking after N records/groups. A single report can combine portrait and landscape oriented pages and the white space at the end of groups can be removed by compressing the page footers. Online report consumption is improved because reports are easier to read.

3. Enhanced Report Designer productivity

- Powerful crosstabs: Summary, variance, and any other customer calculations can be inserted into a crosstab row or a column – especially useful for reports that benefit from a table structure such as financial reports. The crosstab table structure makes reports much faster to build and maintain. This feature also provides powerful benefits to crosstab-based charts since custom formulas in the crosstab can be visualized within the charts.

- Built-in barcode support: Generate barcodes with only a few clicks of the mouse by using the new “turn to barcode” function in the context menu. Easily convert fields to Code39 barcodes without any coding or extra steps. Additional barcode fonts are available from third-party vendors.

- Enhanced designer features: Report designer will be more productive with features like global formula search, duplicate formula, duplicate running total, auto complete field names, and the Find in Field Explorer feature.

- Hyperlinking wizard2: Report designers will save time by automatically creating the Crystal Reports formula required to invoke a BusinessObjects Enterprise OpenDocument hyperlink.

4. New Flexible Deployment Options

- Save reports directly to crystalreports.com: Expand your deployment options with on-demand reporting capabilities when you open and save reports directly to 2 Available only with a BusinessObjects Enterprise XI Release 3 server environment crystalreports.com. This new integration allows you to manage and share your reports securely without dependency on IT.

- Improved XML exporting: Render reports in almost any format and enjoy faster and easier integration with your industry-specific business processes – without any custom coding. The XSLT transformations are embedded into the report file and will be triggered by users from within the viewer when exporting to XML. This provides a powerful, flexible hook for transforming Crystal Reports data and integrating it into other applications.

- Advanced report publishing2: Also known as report bursting, advanced report publishing is a platform for the mass distribution of personalized content. Multiple reports can be created based on different data sources, combined into one desired file format (such as PDF), loaded with personalized content, and then sent to a dynamic list of recipients – with a single action. The content can be archived, printed, or emailed in separate actions, or simultaneously. This makes scheduling much faster and easier, with the ability to conduct cost effective one-on-one marketing campaigns and other personalized high-volume reporting.

5. Improved Report Designer

- Single edition: Crystal Reports 2008 comes in a single edition that is the feature equivalent of the old Developer Edition. This single offering provides customers with quick access to the features they need to meet any application and user requirement. Report samples and developer documentation are now a free, optional download.

- Multilingual reporting: Choose the working language you prefer by simply selecting the language packs you wish to use during product installation. Then switch the report designer UI to use any of the installed language packs. The report content locale can also be explicitly set for each report file. This setting controls sorting, grouping and formatting that matches the local language customs and conventions.

- Reduced install footprint: The download size has been reduced to 250MB to provide fast access via the download site. The runtime files included in developer applications are also significantly smaller.

6. Flexible application integration

- Integrated salesforce.com driver: The salesforce.com driver included with Crystal Reports 2008 allows for easy access to complete customer data – turning it into actionable business information. Reports that use a salesforce.com driver will refresh when deployed to crystalreports.com.

- Enhanced web services data driver: Integration with various web services can be difficult and complex due to a wide variety of implementation types. The new data driver offers additional web access to web services by providing support for RPC encoding of SOAP messages, SSL-secured web servers, as well as a working compatibility with the WS-Security standard. It adapts to custom logon requirements such as email addresses or user/password.

- NET report modification SDK: The Report Application Server SDK is now available for users of CR.NET API without the use of a RAS server. Report modification such as changing / adding / removing database providers, adding / removing / creating report objects, parameters, formulas, and sections can be achieved by accessing the RAS SDK through the CR .NET SDK.

Conclusion


In case you’re looking for Crystal Report 2008 Hosting, you can always consider ASPHostDirectory as the alternatives. We provide the best for you.

What is so SPECIAL on ASPHostDirectory.com Crystal Report 2008 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Crystal Report 2008 Hosting - Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory.com .NET 4 Hosting :: Command Binding in Silverlight 4

clock August 18, 2010 08:44 by author Darwin

To implement the Command binding you have to create a DelegateCommand which implements the ICommand interface. The ICommand interface is available in System.Windows.Input namespace in the System.Windows.dll assembly. It defines the contract for commanding.

- It has an EventHandler “CanExecuteChanged” which occurs when changes occur that affect whether the command should execute.
- It has a method named “CanExecute” and returns boolean value true or false based on whether the command can be executed in its current state.
- Another method named “Execute” which calls when the command is invoked.

Here is the implementation of the ICommand interface:

namespace System.Windows.Input

   public interface ICommand 
   { 
       event EventHandler CanExecuteChanged; 
       bool CanExecute(object parameter); 
       void Execute(object parameter); 
    }
}

Now we have to implement the methods defined in the ICommand interface to our DelegateCommand class. Here is the simple implementation of the same:

using System;
using System.Windows.Input;

namespace Silverlight4.CommandBinding.Demo.CommandBase

    public class DelegateCommand : ICommand
   
        /// <summary> 
        /// Occurs when changes occur that affect whether the command should execute. 
        /// </summary> 
        public event EventHandler CanExecuteChanged;

        Func<object, bool> canExecute; 
        Action<object> executeAction; 
        bool canExecuteCache;

        /// <summary> 
        /// Initializes a new instance of the <see cref="DelegateCommand"/> class. 
        /// </summary> 
        /// <param name="executeAction">The execute action.</param> 
        /// <param name="canExecute">The can execute.</param> 
        public DelegateCommand(Action<object> executeAction, 
                               Func<object, bool> canExecute) 
       
            this.executeAction = executeAction; 
            this.canExecute = canExecute; 
        }

        #region ICommand Members
        /// <summary> 
        /// Defines the method that determines whether the command 
        /// can execute in its current state. 
        /// </summary> 
        /// <param name="parameter"> 
        /// Data used by the command. 
        /// If the command does not require data to be passed, 
        /// this object can be set to null. 
        /// </param> 
        /// <returns> 
        /// true if this command can be executed; otherwise, false. 
        /// </returns> 
        public bool CanExecute(object parameter) 
       
            bool tempCanExecute = canExecute(parameter);

            if (canExecuteCache != tempCanExecute) 
           
                canExecuteCache = tempCanExecute; 
                if (CanExecuteChanged != null) 
               
                    CanExecuteChanged(this, new EventArgs()); 
                
            }

            return canExecuteCache; 
        }

        /// <summary> 
        /// Defines the method to be called when the command is invoked. 
        /// </summary> 
        /// <param name="parameter"> 
        /// Data used by the command. 
        /// If the command does not require data to be passed, 
        /// this object can be set to null. 
        /// </param> 
        public void Execute(object parameter) 
       
            executeAction(parameter); 
       
        #endregion 
    }
}

Implementation of ViewModelBase

Let us now implement the ViewModelBase for our application. Though for this sample application you can directly use the ViewModel, but it is recommended to create a base class implementation by inheriting the INotifyPropertyChanged interface so that, if you are creating multiple ViewModel it will be easier to inherit the base class. Here is the code for that:

using System.ComponentModel;

namespace Silverlight4.CommandBinding.Demo.CommandBase

    public abstract class ViewModelBase : INotifyPropertyChanged 
   
        public event PropertyChangedEventHandler PropertyChanged; 
        /// <summary> 
        /// Called when [property changed]. 
        /// </summary> 
        /// <param name="propertyName">Name of the property.</param> 
        protected void OnPropertyChanged(string propertyName) 
       
            if (PropertyChanged != null) 
           
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 
           
        
    }
}

Implementation of ViewModel

Now our all the base classes are ready to use. Hence, we can go further to create our first ViewModel. In this example we are going to load Customer informations, so we will name it as CustomerViewModel.

First of all we will create a new instance of DelegateCommand “LoadCustomersCommand” which is a ICommand type variable. It takes two parameters. First one is the Action which fires when the command executes and the second one is a Function pointer which returns whether the command can be executed. If it returns true, the command binded to the element will be enabled to do the operation and if it returns false, the command binded to the element will be disabled by default. Once it becomes true by any other operation, the UI thread automatically make the element enabled.

Here in the demo application when the command executes, we will fetch the customer information from the provider and store the data in the ObservableCollection called “CustomerCollection”. We used ObservableCollection because it inherits the INotifyPropertyChanged interface and causes the UI thread to update the UI automatically when the collection changed event occurs binded to the specific UI.

/// <summary>
/// Initializes a new instance of the <see cref="CustomerViewModel"/> class.
/// </summary>
public CustomerViewModel()

    LoadCustomersCommand = new DelegateCommand(LoadCustomers, CanLoadCustomers);
}

/// <summary>
/// Loads the customers.
/// </summary>
/// <param name="parameter">The parameter.</param>
private void LoadCustomers(object parameter)

    CustomerCollection = CustomerProvider.LoadCustomers();
}

/// <summary>
/// Determines whether this instance [can load customers] the specified parameter.
/// </summary>
/// <param name="parameter">The parameter.</param>
/// <returns>
///     <c>true</c> if this instance [can load customers] the specified parameter;
///     otherwise, <c>false</c>.
/// </returns>
private bool CanLoadCustomers(object parameter)

    return true;
}

Implementation of UI (XAML)

As of now, our back end code implmentation is ready and now we have to create our UI to show the customer information. First of all we will create the static instance of the viewmodel as a resource of the UserControl. We named it as “vmCustomer”. Now we will design our UI with a ListBox and a Button. Once we click on the button it should execute the command and load the data in the ListBox.

The ListBox should point it’s ItemSource to the CustomerCollection inside the ViewModel. The button will have the LoadCustomersCommand associated with it. If the canExecute method returns false, you will notice the button as disabled and when it returns true, it will become enabled.

Here is the full XAML implementation:

<UserControl x:Class="Silverlight4.CommandBinding.Demo.MainPage" 
    xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation 
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml 
    xmlns:d=http://schemas.microsoft.com/expression/blend/2008 
    xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
   
xmlns:local="clr-namespace:Silverlight4.CommandBinding.Demo.ViewModel" 
    Width="500" Height="300">

    <UserControl.Resources> 
        <local:CustomerViewModel x:Key="vmCustomer"/>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
        <Border CornerRadius="10,10,0,0" Background="Black" 
                Height="30" VerticalAlignment="Top" Margin="20,20,20,0">
            <TextBlock Text="Silverlight 4 Command Binding Demo" Foreground="White" 
                       FontWeight="Bold" Margin="5"/> 
        </Border> 
        <ListBox ItemsSource="{Binding CustomerCollection, Source={StaticResource vmCustomer}}" 
                 Margin="20,50,20,40"> 
            <ListBox.ItemTemplate> 
                <DataTemplate> 
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="150"/> 
                            <ColumnDefinition Width="150"/> 
                            <ColumnDefinition Width="*"/> 
                        </Grid.ColumnDefinitions> 
                        <TextBlock Text="{Binding Path=Name}" Width="100" Grid.Column="0"/> 
                        <TextBlock Text="{Binding Path=Address}" Width="200" Grid.Column="1"/> 
                        <TextBlock Text="{Binding Path=ContactNumber}" Width="100" Grid.Column="2"/> 
                    </Grid> 
                </DataTemplate> 
            </ListBox.ItemTemplate> 
        </ListBox> 
        <Button Command="{Binding LoadCustomersCommand, Source={StaticResource vmCustomer}}" 
                Content="Load Customers" Height="25" Margin="380,267,20,8" /> 
    </Grid>
</UserControl>

Now, you can run the application and press F5 to run it. Try it.

What is so SPECIAL on ASPHostDirectory.com Silverlight Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Silverlight Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



Cheap Crystal Report 2008 Hosting :: Find Free Crystal Report Tutorial

clock August 10, 2010 08:17 by author Darwin

Instructions

1. Get free Crystal Reports tutorials as part of the support package offered through your software program. For instance, MSDN produces the software Crystal Reports for Visual Studio. On the MSDN, you can find various free Crystal Reports tutorials, including sample code and object model tutorials.

2. Find a Crystal Reports tutorial on coding information websites. Visual Basic Explorer has documentation that includes screenshots that show users the basics of using Crystal Reports for their project reports.

3. Search technical document online libraries to find free Crystal Reports tutorials. TechTutorials has posted a collection of different websites and sources that have free information on how to use Crystal Reports. Click on each link to view different aspects of the program, such as embedding .net applications.

4. View free Crystal Reports video tutorials. Video tutorials can help you visualize the process while having an instructor explain different processes that you can complete while using Crystal Reports. Access multiple Crystal Reports video tutorials for free on the Crystal Reports-Video Tutorials blog. You’ll find text tutorials accompanying the video in order to allow you to save or print the different steps that are involved.

What is so SPECIAL on ASPHostDirectory.com Crystal Report 2008 Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Crystal Report Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!



ASPHostDirectory.com .NET 4 Hosting :: How to Enable Anonymous Access in WSS 3.0

clock August 3, 2010 06:10 by author Darwin

Internet Information Services (IIS) creates the IUSR_computername account to authenticate anonymous users in response to a request for Web content. The IUSR_computername account, where computername is the name of the server that is running IIS, gives the user access to resources anonymously under the context of the IUSR account. You can reset anonymous user access to use any valid Windows account.

In a stand-alone environment, the IUSR_
computername account is on the local server. If the server is a domain controller, the IUSR_computername account is defined for the domain.

By default, anonymous access is disabled by Windows SharePoint Services 3.0 when you create a new Web application. This provides an additional layer of security because IIS rejects anonymous access requests before they can ever be processed by Windows SharePoint Services 3.0 if anonymous access is disabled.

Enable anonymous access for a zone of a Web application

1. From
Administrative Tools, open the SharePoint Central Administration Web site application.

2. On the Central Administration home page, click
Application Management.

3. On the Application Management page, in the
Application Security section, click Authentication providers.

4. On the Authentication Providers page, make sure the Web application that is listed in the
Web Application box (under Site Actions) is the one that you want to configure. If the listed Web application is not the one that you want to configure, click the drop-down arrow to the right of the Web Application drop-down list box and select Change Web Application.

5. In the
Select Web Application dialog box, click the Web application that you want to configure.

6. On the Authentication Providers page, click the zone of the Web application on which you want to enable anonymous access. The zones that are configured for the selected Web application are listed on the Authentication Providers page.

7. On the Edit Authentication page, in the
Anonymous Access section, select Enable Anonymous Access, and then click Save.

At this point, the Web application zone has been enabled for anonymous access.

Enable anonymous access for individual sites

1. Go to the site on which you want to enable anonymous access and click the
Site Actions menu.

2. On the
Site Actions menu, click Site Settings.

3. On the Site Settings page, in the
Users and Permissions section, click Advanced Permissions.

4. On the Permissions page, on the
Settings menu, click Anonymous Access. The settings for anonymous access lists three options:

-
Entire Web site   Select this option if you want to enable anonymous access for the entire Web site.
-
Lists and libraries   Select this option if you want to limit anonymous access to only the lists and libraries on your site.
-
Nothing   Select this option if you want to prevent anonymous access from being used on your site.

5. Click
OK.

At this point, your site is configured for anonymous access based on the options that you have selected.

Enable anonymous access for individual lists

1. Go to the home page of your Web site and, in the left navigation pane, click
View All Site Content

2.
Click the list on which you want to enable anonymous access.

3. On the
Settings menu, click List Settings.

4. On the Customize List page, in the
Permissions and Management section, click Permissions for this list.

5. On the Permissions page, on the
Actions menu, click Edit Permissions. A dialog box is displayed informing you that you are about to create unique permissions for this list. Click OK.

6. On the
Settings menu, click Anonymous Access.

7. Select permissions for users who have anonymous access to the list, and then click
OK.

At this point, users have anonymous access to the list you have configured. You can control whether users have anonymous access to other lists, the home page, or other pages on this site.

Hope this help!!


What is so SPECIAL on ASPHostDirectory.com Sharepoint Hosting?


We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Sharepoint Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: How to Enable Anonymous Access in SharePoint 2007

clock August 2, 2010 06:27 by author Darwin

Follow this steps:

First, you need to enable anonymous on the IIS web site (called a Web Application in SharePoint land). This can be done by:

- Launching Internet Information Services Manager from the Start -> Administration Tools menu
- Select the web site, right click and select Properties
- Click on the Directory Security tab
- Click on Edit in the Authentication and access control section

Instead we’ll do it SharePoint style using the Central Administration section:

- First get to your portal. Then under “My Links” look for “Central Administration” and select it.
- In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
- Select “Authentication Providers” in the “Application Security” section
- Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
- Under “Anonymous Access” click the check box to enable it and click “Save”

NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.

You can confirm that anonymous access is enabled by going back into the IIS console and checking the Directory Security properties.

Now the second part is to enable anonymous access in the site.

- Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site ActionsSite SettingsModify All Site Settings. In WSS it’s under Site ActionsSite Settings.
- Under the “Users and Permissions” section click on “Advanced permissions”
- On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
- Select the option you want anonymous users to have (full access or documents and lists only)

Now users without logging in will get whatever option you allowed them.

A couple of notes about anonymous access:

- You will need to set up the 2nd part for all sites unless you have permission inheritance turned on
- If you don’t see the “Anonymous Access” menu option in the “Settings” menu, it might not be turned on in Central Admin/IIS. You can manually navigate to “_layouts/setanon.aspx” if you want, but the options will be grayed out if it hasn’t been enabled in IIS
- You must do both setups to enable anonymous access for users, one in IIS and the other in each site

Try it!!


What is so SPECIAL on ASPHostDirectory.com Sharepoint Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Sharepoint Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!

 



ASPHostDirectory.com .NET 4 Hosting :: How to Display Row and Column Headers on Multiple Pages

clock July 29, 2010 06:58 by author Darwin

To repeat rows with column headings in a column group area

1. In Design view, right-click the corner handle for a selected tablix data region, and then click Tablix Properties.

2. On the General tab, under Column Headers, select Repeat header columns on each page.


3. Click OK. 

4. Preview the report. The rows that contain the column headings repeat at the start of each page

To repeat rows with column headings for a table with row groups

1. In Design view, select the table. The Grouping pane displays the row groups.


2. On right side of the Grouping pane, click the down arrow, and then click Advanced. The Grouping pane displays static and dynamic tablix members for each group. You can only set properties on a static tablix member.


3. In the Row Groups pane, click the static tablix member for the row that you want to repeat. When you select a static tablix member, the corresponding cell on the design surface is selected, if there is one. The Properties pane displays the properties for the selected tablix member.

4. Set the KeepWithGroup property in the following way:
- For a static row that is above a group, click After
- For a static row that is below a group, click Before.

5. Set the RepeatOnNewPage property to True.

6. Preview the report. If possible, the row repeats with the group on each vertical page that the row group spans.


To repeat columns with row headers in a row group area

1. In Design view, right-click the corner handle for a selected tablix data region, and then click Tablix Properties.


2. On the General tab, under Row Headers, select Repeat header rows on each page.


3. Click OK.


4. Preview the report. If possible, the columns that contain the row headers repeat on each horizontal page.


What is so SPECIAL on ASPHostDirectory.com Reporting Service Hosting?

We know that finding a cheap, reliable web host is not a simple task so we’ve put all the information you need in one place to help you make your decision. At ASPHostDirectory, we pride ourselves in our commitment to our customers and want to make sure they have all the details they need before making that big decision.

We will work tirelessly to provide a refreshing and friendly level of customer service. We believe in creativity, innovation, and a competitive spirit in all that we do. We are sound, honest company who feels that business is more than just the bottom line. We consider every business opportunity a chance to engage and interact with our customers and our community. Neither our clients nor our employees are a commodity. They are part of our family.

The followings are the top 10 reasons you should trust your online business and hosting needs to us:

- FREE domain for Life - ASPHostDirectory gives you your own free domain name for life with our Professional Hosting Plan and 3 free domains with any of Reseller Hosting Plan! There’s no need to panic about renewing your domain as ASPHostDirectory will automatically do this for you to ensure you never lose the all important identity of your site
- 99,9% Uptime Guarantee - ASPHostDirectory promises it’s customers 99.9% network uptime! We are so concerned about uptime that we set up our own company to monitor people’s uptime for them called ASPHostDirectory Uptime
- 24/7-based Support - We never fall asleep and we run a service that is opening 24/7 a year. Even everyone is on holiday during Easter or Christmast/New Year, we are always behind our desk serving our customers
- Customer Tailored Support - if you compare our hosting plans to others you will see that we are offering a much better deal in every aspect; performance, disk quotas, bandwidth allocation, databases, security, control panel features, e-mail services, real-time stats, and service
- Money Back Guarantee - ASPHostDirectory offers a ‘no questions asked’ money back guarantee with all our plans for any cancellations made within the first 30 days of ordering. Our cancellation policy is very simple - if you cancel your account within 30 days of first signing up we will provide you with a full refund
- Experts in Reporting Service Hosting
- Given the scale of our environment, we have recruited and developed some of the best talent in the hosting technology that you are using. Our team is strong because of the experience and talents of the individuals who make up ASPHostDirectory
- Daily Backup Service - We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it
- Easy Site Administration - With our powerful control panel, you can always administer most of your site features easily without even needing to contact for our Support Team. Additionally, you can also install more than 100 FREE applications directly via our Control  Panel in 1 minute!

Happy Hosting!