Posts

Showing posts from October, 2010

MVC and MVVM Architecture

What is MVVM? MVVM is Model View ViewModel. Its a design pattern used widely with Silverlight and WPF applications. We can say it as a successor of MVC pattern. In MVC - Model View Controller , now controller is the view model. View-Model is responsible for exposing the data objects from the Model in such a way that view objects are easily managed and consumed. Why should I use MVVM? 1. MVVM is a great design paatern for UI. 2. Using MVVM you write better, lesser and more manageable code. 3. Being layered changes in UI/views donot majorly affect the other layers. 4. Using MVVM you can create a simple, testable, robust framework on which any WPF/Silverlight applications can thrive. Difference between MVC and MVVM: In MVC input is directed at the Controller first, not the view. Its a Controller that is interfaced with to kick off some functionality. There is a many-to-one relationship between the Controller and the View. That's because a single controller may select di

Free Windows Azure Exam

Microsoft  just announced the availability of beta exam for Windows  Azure . This is beta exam for Exam 71-583, Pro: Designing and Developing Windows Azure  Applications . This exam will be available for free until November 17th. Take this free opportunity to experience a Microsoft certifications exam. Also, it will help you prepare for the main the exam later. If you pass this beta exam, the credit will be added to your transcript and you will not need to take the exam in its released form.   Exam 71-583, Pro: Designing and Developing Windows Azure Applications counts as credit towards MCPD: Windows Azure Developer   4   For more details, visit  http://blogs.technet.com/b/betaexams/archive/2010/10/13/windows-azure-beta-exam-announcement.aspx

Hosting WCF in IIS(9 Steps)

These are the 9 Different steps to Host WCF Application in IIS. 1. Create a Strong Name File - In order to get a Public Key 2. Copy the DLL in the Bin Folder to the Global Assembly Folder 3. Get the name including PublicKeyToken of the DLL eg: Test.WCF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=someToken - Get it from the Properties of the DLL in the Global Assembly Cache - 4. Add it to the svc File eg: <%@ServiceHost Language="C#" Debug="true"   Service="Test.WCF.TestService,Test.WCF,   Version=1.0.0.0, Culture=neutral, PublicKeyToken=51dc0966f715a3f8" %> 5. Create a New Folder in IIS (intpub/wwwroot) 6. Copy the essential files from the project folder to the created New Folder 7. Set Permission to the folder via IIS 8. Run resetiis command 9. Test the Web Service

Free Microsoft Silverlight 4 Exam

Register for Beta Exam  71-506,  TS: Silverlight 4, Development You are invited to take beta exam 71-506, TS: Silverlight 4, Development. If you pass the beta exam, the exam credit will be added to your transcript and you will not need to take the exam in its released form. The 71-xxx identifier is used for registering for beta versions of MCP exams, when the exam is released in its final form the 70-xxx identifier is used for registration. By participating in beta exams, you have the opportunity to provide the Microsoft Certification program with feedback about exam content, which is integral to development of exams in their released version. We depend on the contributions of experienced IT professionals and developers as we continually improve exam content and maintain the value of Microsoft certifications. Exam 71-506, TS: Silverlight, Development counts as credit towards the following certification(s). MCTS: Silverlight 4 Development Availability Registration begins: Octo

Store/Retrieve image from DataBase

Store Image: SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); con.Open(); byte[] ImgBytes = new byte[flurl.PostedFile.InputStream.Length]; flurl.PostedFile.InputStream.Read(ImgBytes, 0, ImgBytes.Length); string qry = "Insert into Table1(ImageData) values(@ImageData)"; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@ImageData", ImgBytes); cmd.ExecuteNonQuery(); con.Close(); Retrieve Image: private string dumpImageToFile ( ref Byte[] img ) { string strTempPath = System.IO.Path.GetTempPath (); // Create the file name string strFileName = strTempPath + "\\" + ".img"; // Copy raw data to a memory stream System.IO.FileStream fs = new FileStream( strFileName, FileMode.OpenOrCreate, FileAccess.Write ); int offset = 0; fs.Write( img, offset, img.Length - offset ); // Close stream fs.Close(); fs = null; return strFileName; } catch ( System.IO.IOExcep

AlwaysVisibleControlExtender AJAX Control

For AlwaysVisibleControlExtender .aspx code is: <asp:Panel ID=”Panel1″ BorderStyle=solid BorderWidth=2 runat=”server” Height=”30px” Width=”30%”    BackColor=yellow BorderColor=red> <strong> <span style=”font-family: Verdana”>Current Time:  </span> </strong> <asp:Label ID=”Label1″ runat=”server” Font-Bold=”True” Font-Names=”Verdana” Font-Size=”10pt” Text=”"> </asp:Label> <a target=”_blank” href=”http://google.com”>Click Me</a> </asp:Panel> <asp:AlwaysVisibleControlExtender ID=”ace” runat=”server”    TargetControlID=”Panel1″ VerticalSide=”Middle”    VerticalOffset=”10″    HorizontalSide=”Right”    HorizontalOffset=”10″     ScrollEffectDuration=”0.1″    /> Javascript Code: <script type=”text/javascript” language=”javascript”> function ShowTime() { var dt = new Date(); document.getElementById(“<%= Label1.ClientID %>”).innerText =  dt.toLocaleTimeString(); window.setTimeout(“ShowTime()”, 1000); } window.set

AnimationExtender AJAX Control

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”DotNetSpider.aspx.cs” Inherits=”DotNetSpider” %> <%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”asp” %> <%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit.HTMLEditor” TagPrefix=”asp” %> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head runat=”server”> <title></title> <style type=”text/css”> .flyOutDiv{ display: none; position: absolute; width: 250px; z-index: 3; opacity: 0; filter:(progid:DXImageTransform.Microsoft.Alpha(opacity=0)); font-size: 14px; border: solid 1px #CCCCCC; background-color: #FFFFFF; padding: 5px; } .flyOutDivCloseX{ background-color: #666666; color: #FFFFFF; text-align: center; font-weight: bold; text-decoration: none; border: outset thin #FFFFFF; padding: 5px; } </style

AsyncFileUpload AJAX Control

//.aspx Code: <head runat=”server”> <title>::AsyncFileUpload::</title> <script type=”text/javascript” language=”javascript”> function uploadError(sender, args) { document.getElementById(‘lblStatus’).innerText = args.get_fileName(), “<span style=’color:red;’>” + args.get_errorMessage() + “</span>”; } function StartUpload(sender, args) { document.getElementById(‘lblStatus’).innerText = ‘Uploading Started.’; } function UploadComplete(sender, args) { var filename = args.get_fileName(); var contentType = args.get_contentType(); var text = “Size of ” + filename + ” is ” + args.get_length() + ” bytes”; if (contentType.length > 0) { text += ” and content type is ‘” + contentType + “‘.”; } document.getElementById(‘lblStatus’).innerText = text; } </script> </head> <body> <form id=”form1″ runat=”server”> <asp:ScriptManager ID=”ScriptManager1″ runat=”server”></asp:ScriptManager> <div> <asp:AsyncFileUpload ID=”A

.Net Questions/Answers

Q1: what are access modifiers? A:   1. Public Public means visible to everyone and everywhere. 2.Private Private means hidden and usable only by the class itself. No code using a class instance can access a private member and neither can a derived class. Information or functionality that will not be needed or has no meaning outside of the context of a specific class should be made private. 3.Protected Protected members are similar to private ones in that they are accessible only by the containing class. However, protected members also may be used by a descendant class. So members that are likely to be needed by a descendant class should be marked protected. 4. Internal Internal are public to the entire assembly but private to any outside assemblies. Internal is useful when you don’t want to allow other assemblies to have the functionality. 5. Protected internal Finally, we have the only compound access modifier allowed in .NET. Members marked as protected internal may be accessed onl