Wickasitha's tech Blog

blogging everything

A code sample is worth a thousand words.  Here are a few projects to take a look at that go beyond just code snippets to show you how to put key technologies together in the form ofsample applications.  (Note, if you are looking for just code snippets and focused codesamples, you can check out the Microsoft All-in-One Code Framework project site on CodePlex.)

Layered Architecture Solution Guidance
Project Site - http://layerguidance.codeplex.com

”Designing and creating layered applications can be a challenging task to developers. Layered Architecture Solution Guidance is a Microsoft Visual Studio 2010 extension that provides a set of tools and guidance aimed at simplifying the development of layered applications.
Layered Architecture Solution Guidance is a 
Guidance Automation Extension that integrates with Microsoft Visual Studio 2010 to allow developers to easily create and organize their projects in a layered fashion following the structure that is illustrated in the Layered Architecture Sample for .NET. It provides a set of solution templates integrated with a suite of code generators to make developing layered applications much simpler and quicker.

Microsoft Spain – Domain Oriented N-Layered .NET 4.0 Sample App
Project Site - http://microsoftnlayerapp.codeplex.com/

The main goal is to show how to use .NET 4.0 wave technologies implementing typical DDD patterns: N-Layered Architecture, Domain Entities, Aggregates, Repositories, Unit of Work, Domain Services, Application Services, DTOs, DTO-Adapters, etc.

Read full article

Microsoft Has Bought Skype For $8.5 Billion

  • Tuesday May 10,2011 08:35 AM
  • By wickasitha
  • In Microsoft

Skype CEO Tony Bates

Skype CEO Tony Bates

Last week, it was Google and Facebook who were said to be purchasing Skype. Today, Microsoft has announced that actually? They’re the ones snapping up the VoIP company. The confirmed price is $8.5 billion; considerably more than what eBay bought Skype for back in 2005.

So what is Microsoft getting out of the deal? Not just the secrets to Skype’s phenomenal success. Microsoft’s said that Skype “will support Microsoft devices like Xbox and Kinect, Windows Phone and a wide array of Windows devices, and Microsoft will connect Skype users with Lync, Outlook, Xbox Live and other communities.”

read more

Retrieve value of Dynamic controls in asp.net

The main object of this article is to access value of  asp.net controls which are generated dynamically. For this, we will save viewstate of dynamic controls.
Suppose we have one dropdown and one button. When user selects “Generate” option, the Dynamic table will be generated. In each cell of table there will be textbox. User enters value in the textboxes and click on button then it will display all user entered values.

In aspx page:

<form id="form1" runat="server">
<div>
<asp:Table ID="tbl" runat="server">
</asp:Table>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Select...</asp:ListItem>
<asp:ListItem>Generate</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSet" runat="server" Text="Button" onclick="btnSet_Click" /> </div>
</form>

To create dynamic control:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 1)
{
CreateDynamicTable();
}
}
private void CreateDynamicTable()
{
// Fetch the number of Rows and Columns for the table
// using the properties
int tblRows = 5;
int tblCols = 5;
// Now iterate through the table and add your controls
for (int i = 0; i < tblRows; i++)
{
TableRow tr = new TableRow();
for (int j = 0; j < tblCols; j++)
{
TableCell tc = new TableCell();
TextBox txtBox = new TextBox();
txtBox.ID = "txt-" + i.ToString() + "-" + j.ToString();
txtBox.Text = "RowNo:" + i + " " + "ColumnNo:" + " " + j;
// Add the control to the TableCell
tc.Controls.Add(txtBox);
// Add the TableCell to the TableRow
tr.Cells.Add(tc);
}
// Add the TableRow to the Table
tbl.Rows.Add(tr);
tbl.EnableViewState = true;
ViewState["tbl"] = true;
}
}
On Button click:
protected void btnSet_Click(object sender, EventArgs e)
{
foreach (TableRow tr in tbl.Controls )
{
foreach (TableCell tc in tr.Controls)
{
if (tc.Controls[0] is TextBox)
{
Response.Write(((TextBox)tc.Controls[0]).Text);
}
}
Response.Write("<br/>");
}
}

Right Now, No output because dynamic controls are lost in postback .So we need to save dynamic controls value and generate dynamic controls again.we need to maintain viewstate.

protected override object SaveViewState()
{
object[] newViewState = new object[2];
List<string> txtValues = new List<string>();
foreach (TableRow row in tbl.Controls)
{
foreach (TableCell cell in row.Controls)
{
if (cell.Controls[0] is TextBox)
{
txtValues.Add(((TextBox)cell.Controls[0]).Text);
}
}
}
newViewState[0] = txtValues.ToArray();
newViewState[1] = base.SaveViewState();
return newViewState;
}
protected override void LoadViewState(object savedState)
{
//if we can identify the custom view state as defined in the override for SaveViewState
if (savedState is object[] && ((object[])savedState).Length == 2 && ((object[])savedState)[0] is string[] )
{
object[] newViewState = (object[])savedState;
string[] txtValues = (string[])(newViewState[0]);
if (txtValues.Length > 0)
{
//re-load tables
CreateDynamicTable();
int i = 0;
foreach (TableRow row in tbl.Controls)
{
foreach (TableCell cell in row.Controls)
{
if (cell.Controls[0] is TextBox && i < txtValues.Length)
{
((TextBox)cell.Controls[0]).Text = txtValues[i++].ToString();
}
}
}
}
//load the ViewState normally
base.LoadViewState(newViewState[1]);
}
else
{
base.LoadViewState(savedState);
}
}

Parallel Computing Virtual Labs on MSDN

Interested in trying out the support for parallel computing in Visual Studio 2010 or .NET 4,  You can now use the MSDN Virtual Labs site to try these out from the comforts of your favorite browser.  Multiple labs are available:

The Ads

Rather than tell you how great-looking and clever the new ads for Windows Phone 7 are, I thought I’dshow them instead. Here’s the first one, which features Donovan’s song, Season of the Witch:

Here’s the other one, which asks this question: “Really?” (In case you were wondering, the tune is In the Hall of the Mountain King by Edvard Grieg.)

The message in both these ads is pretty simple: Smartphones eat up a lot of your attention and time. Wouldn’t it be nice if there was one that didn’t do that?

There are lots of little goodies in Windows Phone 7 that address this issue. The ones I can think of off the top of my head include:

  • The lock screen. You don’t have to unlock your phone just to find out what the next appointment on your calendar is. The lock screen displays it, along with the date, time and the number of voice and text messages you have.
  • The Start page. The start page is where you pin your favourite and often-used items so you can access them quickly, so you don’t have to riffle through page after page of apps.
  • What you can pin to the Start page. You can pin more than just apps to the Start page. Is there someone – a spouse, significant other, friend or family member – whom you phone, text, or email often? Pin that person to the Start page! Is there a website you hit many times a day? Pin it to the Start page!
  • Communicating quickly with people. The People Hub on your phone makes looking up and reaching people fast and easy. Tap on a person for all the ways to reach him or her and tap on any of one of those ways to start communicating. A quick swipe shows you that person’s Facebook updates. Getting in touch and keeping up is pretty easy with this UI.
  • Finding. The context-sensitive Search button is all about finding what you need, whether it’s some information on your phone, on the web or in the real world, and you get this all from a single button press.

What?

Zoom.it is a free service for viewing and sharing high-resolution imagery. You give us the link to any image on the web, and we give you a beautiful new way to experience it — along with a nice short URL.

How?

Zoom.it converts your image to the Deep Zoom format, which lets you smoothly and efficiently explore the whole image, no matter how large. Check out Deep Zoom Studio for examples of this technology in action.

Zoom.it runs on Windows Azure and enhances the experience with Microsoft Silverlight when available.

Who?

Zoom.it was created by Microsoft Live Labs, the same folks who brought you Photosynth and Pivot.

So what are you waiting for? Create your own! »

Canceling an async postback – ASP.NET AJAX

  • Tuesday May 11,2010 12:38 AM
  • By wickasitha
  • In AJAX, ASP.NET

Recently a new requirement came for cancel an async operation.  Being aware of the abortPostBack method the PageRequestManager, I figured that it would be pretty simple to implement this feature.  I added a ‘Cancel’ button to my progress indicator and wired the onclick handler to invoke the abortPostBack method.

Clicking cancel did abort the async postback however, because the OnUpdated animation only runs when the UpdatePanel is updated my indicator was never being hidden and it was appearing as if the application was hanging.   My approach to solving this was to look-up the animation component and invoke the animation myself.  like this:

 function abort(){
        var prm = Sys.WebForms.PageRequestManager.getInstance();
        if(prm get_isInAsyncPostBack()){
            //  abort the postback
            prm abortPostBack();
            //  get the reference to the animation for the gridview
            var animation = $find('animation');
            //  simulate stopping by replaying the animation
            animation._postBackPending = false;
            animation.get_OnUpdatingBehavior().quit();
            animation.get_OnUpdatedBehavior().play();
        }
    }
SOURCE
 (more...)

RSS Feeds

QR Code

qr code

QR code created by QR code Widget

Fun with .NET

Visitors

Your Ads Here
Promote your products