<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7178878378157985534</id><updated>2011-11-27T16:30:59.274-08:00</updated><category term='Html Host'/><category term='LINQ'/><category term='Maps'/><category term='Silverlight Div'/><category term='Reports'/><category term='DeepEarth'/><category term='Hosting'/><category term='HtmlDocument'/><category term='HtmlElement'/><category term='Sql 2008'/><category term='Error'/><category term='Silverlight 2'/><category term='Html'/><category term='IIS'/><category term='Web Service'/><category term='PlaceMarkers'/><category term='Silverlight'/><category term='Datagrid'/><title type='text'>Technical Snippets on C#, Silverlight</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-5996781416212832134</id><published>2009-10-20T22:02:00.000-07:00</published><updated>2009-10-20T22:10:10.585-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Web Service'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>Silverlight Web Services deployment</title><content type='html'>&lt;p&gt;One of the usual issues a newbie developer has with silverlight is with the webservice deployment. Everything would work fine when the services are developed along with the silverlight application but it won't work when it gets deployed to the target server.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;  The usual reason for this is the url references of the application won't be updated when the deployment is done. In order to make sure that this issue doesn't repeat every time, we can invoke the web services in the silverlight app in such a way that it never needs updating the urls.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;  A sample snippet of how to do this is as below. We use the Application.Current.Host.Source.AbsoluteUri variable which holds the value of the abolute path of the uri being accessed.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;   int index = Application.Current.Host.Source.AbsoluteUri.IndexOf(Application.Current.Host.Source.AbsolutePath);&lt;br /&gt;  String myCurrentHostUrl = Application.Current.Host.Source.AbsoluteUri.Remove(index + 1); &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;p&gt;myCurrentHostUrl contains the value of the website where I am hosting this. Now I can invoke my webservice with this url.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  BasicHttpBinding basicHttp = new BasicHttpBinding();&lt;br /&gt;  EndpointAddress endPoint = new EndpointAddress(myCurrentHostUrl + @"WebServices/MyWebService.svc");&lt;br /&gt;  MyWebServiceClient client = new MyWebServiceClient(basicHttp, endPoint);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;p&gt; We can simply put this code in a reusable function and keep using this as and when needed. Hope this helps. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-5996781416212832134?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/5996781416212832134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=5996781416212832134' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/5996781416212832134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/5996781416212832134'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/10/silverlight-web-services-deployment.html' title='Silverlight Web Services deployment'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-5191481533297443968</id><published>2009-04-23T16:49:00.000-07:00</published><updated>2009-04-24T22:14:55.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight 2'/><category scheme='http://www.blogger.com/atom/ns#' term='Hosting'/><title type='text'>Checklist for Hosting a Silverlight Application</title><content type='html'>I used to have some small if not huge issues because of some issues&lt;span&gt; not known before. So thought a compilation of some notes will be helpful to others as well. Feel free to send me a few more to add to these points.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Creating the application&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;: &lt;/span&gt;&lt;br /&gt;The Silverlight Application can be created normally along with class libraries supporting silverlight. The final compiled control is a .xap file. This is a no brainer, I have just used this as a filler to start the blog post. :)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Web Service Reference Urls: &lt;/span&gt;&lt;br /&gt;Many people miss this part. We need to update the service reference urls to the new server where we are going to host the application. Instead if we want this to dynamically change, you can use the following code snippet to invoke the Web Services. This is the best idea instead of manually changing it either by update reference or change in servicereferences.clientconfig.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;BasicHttpBinding basicHttpBinding = new BasicHttpBinding();&lt;br /&gt;EndpointAddress endPoint = new EndpointAddress(GetApplicationUrl("/MyService.svc"));&lt;br /&gt;MyWebServiceClient client = new MyWebServiceClient(basicHttpBinding, endPoint);&lt;br /&gt;client.CallYourFunction();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In the above code, you need to write the Get Application Url function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Security &amp;amp; HttpContext issue:&lt;/span&gt;&lt;br /&gt;I had a problem with the Asp .net Application Security. I can &lt;a href="http://blogs.msdn.com/brada/archive/2008/05/03/accessing-the-asp-net-authentication-profile-and-role-service-in-silverlight.aspx"&gt;login and logout using the Membership provider using Brad Adam's article&lt;/a&gt; . But I wanted to verify the security at different places in my web services.&lt;br /&gt; And the problem is &lt;span style="font-style: italic;"&gt;WCF does not carry the HttpContext with it &lt;/span&gt;and different calls to WCF web services will result in HttpContext returning null references to the logged on member.&lt;br /&gt;The solution is to use host headers and send it back and forth. For example we can send the username and password as headers and then call the Membership.ValidateUser(username, password). A sample snippet is as below.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Snippet on the Silverlight Side:&lt;/span&gt;&lt;br /&gt;  You can download the code for the client side use from &lt;a href="http://code.msdn.microsoft.com/silverlightws/Release/ProjectReleases.aspx?ReleaseId=1660"&gt;Microsoft site at Silverlight Message Inspector&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Snippet on the Web Service Side:&lt;/span&gt;&lt;code&gt;&lt;br /&gt;String userName = OperationContext.Current.IncomingMessageHeaders.GetHeader&lt;string&gt;("UserName", "");&lt;br /&gt;String password = OperationContext.Current.IncomingMessageHeaders.GetHeader&lt;string&gt;("Password", "");&lt;br /&gt;&lt;br /&gt;bool isAuthenticated = Membership.ValidateUser(userName, password);&lt;br /&gt;&lt;br /&gt;&lt;/string&gt;&lt;/string&gt;&lt;/code&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;WCF Service Issues:&lt;/span&gt;&lt;br /&gt;The first thing you can try when there is an issue with web service is to load the webservice.svc file directly in Internet Explorer. If you are hosting on a shared hoster who already supports silverlight and webservice, then you will usually need to create your own service host factory.&lt;br /&gt;Otherwise the error will be displayed like "WCF does not support multiple IIS bindings for the same protocol (here it is HTTP) for the same web site". A short blog post regarding this can be found at &lt;a href="http://www.darkside.co.za/archive/2008/02/21/custom-servicehostfactory-for-wcf-and-iis.aspx"&gt;http://www.darkside.co.za/archive/2008/02/21/custom-servicehostfactory-for-wcf-and-iis.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;IIS Settings:&lt;/span&gt;&lt;br /&gt;If you are hosting on your personal machine or a dedicated server, then you will have to set the "Advanced Multiple WebSite Configuration".&lt;br /&gt;We need to add our website name into the IIS Console --&gt; Properties --&gt; Web Site Tab --&gt; click "Advanced" button. This will enable our web services to return the host url as our website instead of returning the machine name, which won't be visible to the outside public.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_e-y2oeuQDfU/SfKTzO7Ip6I/AAAAAAAAAL8/tIKSG1fHygE/s1600-h/MultipleSiteHost.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 270px; height: 320px;" src="http://1.bp.blogspot.com/_e-y2oeuQDfU/SfKTzO7Ip6I/AAAAAAAAAL8/tIKSG1fHygE/s320/MultipleSiteHost.JPG" alt="" id="BLOGGER_PHOTO_ID_5328483817521457058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Also I have seen occasional problems because the .svc is not registered. In order to do this use the command&lt;br /&gt;&lt;code&gt;&lt;br /&gt;C:\WINDOWS\WinFX\v3.0\Windows Communication Foundation\servicemodelreg.exe -i&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Support for Firefox and IE:&lt;/span&gt;&lt;br /&gt;There are issues with hosting a silverlight application in an aspx page and using it in firefox. So what I do is to detect the requesting browser and if it is FireFox then I redirect the request to the silverlighthost.html file. A sample snippet is below.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;window.onload = function()&lt;br /&gt;{&lt;br /&gt;if (navigator.appName == 'FireFox')&lt;br /&gt;{&lt;br /&gt;window.location = 'silverlighthost.html';&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;document.getElementById('Xaml1').focus();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-5191481533297443968?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/5191481533297443968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=5191481533297443968' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/5191481533297443968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/5191481533297443968'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/04/hosting-silverlight-application.html' title='Checklist for Hosting a Silverlight Application'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_e-y2oeuQDfU/SfKTzO7Ip6I/AAAAAAAAAL8/tIKSG1fHygE/s72-c/MultipleSiteHost.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-4710516369202401222</id><published>2009-04-13T17:04:00.001-07:00</published><updated>2009-04-24T22:16:36.379-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight Div'/><category scheme='http://www.blogger.com/atom/ns#' term='HtmlElement'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>Dynamically creating a DIV control in Silverlight</title><content type='html'>By now everyone would have gotten a clear idea that HtmlPage, HtmlDocument along with HtmlElement is the way to display a div item in silverlight pages. Now here are few samples to create some controls dynamically from a silverlight page using Html Dom bridge.&lt;br /&gt;  For those who wonder what is the difference between a Html Silverlight Dom bridge and HTML Overlay, Html overlay needs the windowless parameter to be set and gives the rendering job to the browser, but Html Silverlight Dom model won't.&lt;br /&gt;  There is an excellent FAQ article by erikreitan on the Html and Java script in silverlight http://blogs.msdn.com/erikreitan/archive/2008/12/02/silverlight-html-bridge-faq.aspx. Take a look at this article when you get some time.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    HtmlDocument doc = HtmlPage.Document;&lt;br /&gt;    HtmlElement dynamicDiv = doc.CreateElement("div");&lt;br /&gt;    dynamicDiv.SetAttribute("id", System.Guid.NewGuid().ToString());&lt;br /&gt;    dynamicDiv.SetStyleAttribute("height", "20px");&lt;br /&gt;    dynamicDiv.SetStyleAttribute("width", "800px");&lt;br /&gt;    dynamicDiv.SetProperty("innerhtml", "A small sample of dynamically added div from silverlight");&lt;br /&gt;    doc.Body.AppendChild(dynamicDiv);&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;  Remember to include the 'System.Windows.Browser' namespace for this code to compile.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-4710516369202401222?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/4710516369202401222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=4710516369202401222' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/4710516369202401222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/4710516369202401222'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/04/dynamically-creating-div-control-in.html' title='Dynamically creating a DIV control in Silverlight'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-7281254402106721492</id><published>2009-04-10T22:36:00.000-07:00</published><updated>2009-04-24T22:16:15.765-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HtmlDocument'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight Div'/><category scheme='http://www.blogger.com/atom/ns#' term='HtmlElement'/><category scheme='http://www.blogger.com/atom/ns#' term='Html'/><title type='text'>How to use Html Div in silverlight using Silverlight Html bridge</title><content type='html'>We all understand that Silverlight has not matured into a full blown Line of Business Applications platform and time and again we have to interact with HTML Dom for most of our work. I've tried to consolidate how to access an existing element and add a new div element dynamically. Let's look at how to access the existing elements and do some modifications to it.&lt;br /&gt;&lt;br /&gt;&lt;devlive:slscontrol silverlightVersion="2.0" src="/96968/HtmlSilverlight/"&gt;&lt;br /&gt;    &lt;div id="silverlightdiv" &gt;&lt;br /&gt;    &lt;p&gt;This is the DIV you are supposed see some changes when you click buttons. But this is not working yet because of incompatibility with blogger and the xap hosting. &lt;/p&gt;&lt;br /&gt;    &lt;/div&gt;&lt;br /&gt;&lt;/devlive:slscontrol&gt;&lt;br /&gt;&lt;b&gt;Accessing the existing elements:&lt;/b&gt;&lt;br /&gt;  Silvelright packages all the Html Dom content under the &lt;code&gt;System.Windows.Browser&lt;/code&gt; assembly/namespace. Let's assume we have a div in our Html page where the silverlight control is going to be hosted.&lt;br /&gt;  I've tried both setting as well as getting the &lt;code&gt;innerhtml&lt;/code&gt; property of the div control we used. The code for the Div in your html or aspx page is added as follows.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    &amp;lt;div id="silverlightdiv"&amp;gt;&lt;br /&gt;    &amp;lt;p&amp;gt;hello world&amp;lt;/p&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt; Now our Page.xaml.cs will be able to access the "silverlightdiv" using HtmlElement properties. A short snippet for getting and setting the property are as below.&lt;br /&gt;&lt;b&gt;Getting the InnerHtml property: &lt;/b&gt;&lt;br /&gt; &lt;code&gt;&lt;br /&gt; HtmlElement mysilverlightdiv = HtmlPage.Document.GetElementById("silverlightdiv");&lt;br /&gt; Object obj = mysilverlightdiv.GetProperty("innerhtml");&lt;br /&gt; String str = obj.ToString();&lt;br /&gt; MessageBox.Show(str);&lt;br /&gt; &lt;/code&gt; &lt;br /&gt;&lt;b&gt;Setting the InnerHtml property:&lt;/b&gt;&lt;br /&gt; &lt;code&gt;&lt;br /&gt; HtmlElement mysilverlightdiv = HtmlPage.Document.GetElementById("silverlightdiv");&lt;br /&gt; mysilverlightdiv.SetProperty("innerhtml", txtHtmlText.Text);&lt;br /&gt; &lt;/code&gt;&lt;br /&gt; This technique do not use the overlay (which needs the windowless=true to be set), but uses the HTML Dom bridge provided by silverlight. Also for setting the CSS properties of the div should be done using the SetStyleAttribute funtion of the HtlmElement class. A look at the code snippet for changing an attribute is as follows.&lt;br /&gt;&lt;b&gt;Setting a CSS Property:&lt;/b&gt;&lt;br /&gt; &lt;code&gt;&lt;br /&gt; HtmlElement mysilverlightdiv = HtmlPage.Document.GetElementById("silverlightdiv");&lt;br /&gt; mysilverlightdiv.SetStyleAttribute("color", "red" );&lt;br /&gt; &lt;/code&gt;&lt;br /&gt;&lt;h3&gt;Download Source&lt;/h3&gt;&lt;br /&gt;You can download the Visual Studio 2008 control source file/project from &lt;a href='http://www.codersource.net/silverlightcode/htmlsilverlight/HtmlSilverlight.zip'&gt;HtmlSilverlight&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-7281254402106721492?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/7281254402106721492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=7281254402106721492' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7281254402106721492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7281254402106721492'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/04/how-to-use-html-div-in-silverlight.html' title='How to use Html Div in silverlight using Silverlight Html bridge'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-7305983406686763188</id><published>2009-04-10T17:56:00.000-07:00</published><updated>2009-04-24T22:15:53.015-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Reports'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>Report Viewer for Silverlight 2</title><content type='html'>Silverlight platform has aroused interest in developing Line of Business Apps for a lot of people. But Microsoft has not given any Reporting control features with its release of silverlight. This is sort of a difficult balance that developers have to take in terms of giving a rich UI with support for .net programming.&lt;br /&gt;  &lt;br /&gt;  Neither any popular Microsoft Platform Controls vendors have come up with any innovative ideas. Perpetuum soft has a solution, but I am not convinced at the solution as it asks for us to write code and create a dataset for displaying reports. For me ideally the reporting platform should take care of all the data plumbing, formatting, paging, printing etc., Also I wanted to use Microsoft SQL Server reports in Remote mode to be shown in the silverlight platform. &lt;br /&gt;  &lt;br /&gt;  Currently as I see there is only one way of doing these reports. Create your reports definition files in Sql 2005 or 2008 and then use an aspx page to load them. A short reference for the code snippet. It is better to place this in the page_load event of the aspx page.&lt;br /&gt;  &lt;br /&gt;  And currently there are 2 ways to display the aspx pages (which host the Report viewer control) in silverlight.&lt;br /&gt;&lt;br /&gt;  1. Use the div parameter in combination with javascript to display the control.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;  &lt;br /&gt;        ReportParameter[] parm = new ReportParameter[1];&lt;br /&gt;        parm[0] = new ReportParameter("id",1);&lt;br /&gt;        ReportViewer1.ShowCredentialPrompts = false;&lt;br /&gt;        ReportViewer1.ServerReport.ReportServerUrl = "Replace with Report Server Url";&lt;br /&gt;        ReportViewer1.ServerReport.ReportPath = "Replace with Report Path Name";&lt;br /&gt;        ReportViewer1.ServerReport.SetParameters(parm);&lt;br /&gt;        ReportViewer1.ServerReport.Refresh();&lt;br /&gt;&lt;/code&gt;  &lt;br /&gt;&lt;br /&gt;   This can use a Html Host control like &lt;a href='http://csharp-snippets.blogspot.com/2009/03/html-host-control-in-silverlight.html'&gt;Html Host Using IFrame&lt;/a&gt; or the c1HtmlHost provided by ComponentOne as well.&lt;br /&gt;   &lt;br /&gt;   This solution now can support all features needed for a reporting platform. But obviously using windowless property to show the Html in the browser leaves the browser to manage your silverlight app and has an impact on performance.&lt;br /&gt;   &lt;br /&gt;   2. And the second option is write your own reporting solution. I am not good at it yet :). &lt;br /&gt;&lt;br /&gt;   Please contact me if you have better ideas of doing a solution for reporting in silverlight. Will be glad to hear those.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-7305983406686763188?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/7305983406686763188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=7305983406686763188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7305983406686763188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7305983406686763188'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/04/report-viewer-for-silverlight-2.html' title='Report Viewer for Silverlight 2'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-193477691330602497</id><published>2009-03-28T17:19:00.000-07:00</published><updated>2010-05-14T03:46:44.066-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='HtmlDocument'/><category scheme='http://www.blogger.com/atom/ns#' term='Html Host'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Html'/><title type='text'>Html Host control in Silverlight</title><content type='html'>&lt;p&gt;&lt;b&gt;The revised and latest version of this control can be found at &lt;a href="http://www.codersource.net/AspNet/Silverlight/SilverlightHtmlHostcontrolRevised.aspx"&gt;revised silverlight htmlhost&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;It is generally a problem in silverlight to use the HTML content. First and foremost problem is the trouble with setting the position of the control based on the silverlight page we are creating. Also it is really clunky to write the code to read and write your div details by accessing the HTML DOM objects.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Ofcourse Silverlight exposes these HTML DOM objects in the System.Windows.Browser namespace by the classes like HTMLDocument, HTMLElement, HTMLPage etc., These classes provide functions like CreateElement, which can create the controls we want. I've used this function to create the IFRAME which I finally position properly on the page using some properties exposed.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This is a clean way of using the HTML IFrame in your code. Feel free to use the source and add more functionality. If you think your new functionality may be useful to someone else, pls let me know by dropping an email to muthu.v (@) g mail dot com.&lt;br /&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style="font-size:100%;"&gt;How the Html Host control was built:&lt;/span&gt;&lt;/h2&gt;&lt;p&gt;This creates a DIV inside the HTMLPage.Document.Body and adds an IFRAME object to the DIV control. This uses the classes like HtmlDocument, HtmlElement, HtmlPage for creating these and adds them to the HTML Document object. This has been tested to work fine in IE8 and FireFox. If any of you find any issues and fixes, pls let me know I'll fix and upload again. That will be useful to our programming community.&lt;/p&gt;I've not added much of design time support. So after adding the control, you need to call a function &lt;span style="FONT-STYLE: italic"&gt;InitControl&lt;/span&gt;() for this to be rendered. Also positioning of the control can be done by using the properties &lt;i&gt;HtmlControlTop&lt;/i&gt; and &lt;i&gt;HtmlControlLeft&lt;/i&gt; properties. Width and Height are exposed as "Width" and "Height" only.&lt;br /&gt;&lt;b&gt;How to use the Html Host control:&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a new Silverlight application or add a new Silverlight User Control (page) into your existing application.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Reference the FreeHtmlHost.dll in the project.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add the namespace reference to the silverlight user control on the top like this.&lt;br /&gt;&lt;p&gt;&lt;code&gt;xmlns:cust="clr-namespace:FreeHtmlHost;assembly=FreeHtmlHost"&lt;/code&gt;&lt;br /&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;Add the control in the location you want like this. Adjust the position of the controls according to your needs.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;cust:FreeHtmlHost x:Name="customHost" Width="620" HtmlControlTop="50" HtmlControlLeft="30" Height="500" NavigationUrl="http://www.microsoft.com"/&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Call the &lt;code&gt;customHost.InitControl();&lt;/code&gt; function in the Page load event of the control or the constructor of your Page.xaml.cs file after the 'InitializeComponent()' function. &lt;/li&gt;&lt;/ol&gt;The &lt;code&gt;isWindowless&lt;/code&gt; property determines whether the HTML is displayed on top of silverlight. If set to true, the HTML controls behind the silverlight plugin are displayed and if false, the silverlight is displayed on top of HTML. &lt;span style="FONT-STYLE: italic"&gt;This must be set to &lt;span style="FONT-WEIGHT: bold"&gt;true &lt;/span&gt;while using this HTML host control&lt;/span&gt;.&lt;br /&gt;&lt;p&gt;There is another option of background=transparent which makes the background of the plugin to invisible. This option should be avoided as this might hit the performance of the app. We need not worry about this property for using this control. Leave it to its default.&lt;/p&gt;&lt;p&gt;There is another property &lt;span style="FONT-WEIGHT: bold"&gt;enableHTMLAccess &lt;/span&gt;property which provides a layer of security to specify whether the silverlight code should access HTML DOM or not. This is by default set to true even if you don't use it.&lt;/p&gt;&lt;p&gt;&lt;span style="FONT-WEIGHT: bold"&gt;Download Source:&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You can download the Visual Studio 2008 control source file at &lt;a href="http://www.codersource.net/silverlightcode/htmlhost/FreeHtmlHost.zip"&gt;FreeHtmlHost&lt;/a&gt; source.&lt;br /&gt;&lt;/p&gt;The sample code using this library can be found at &lt;a href="http://www.codersource.net/silverlightcode/htmlhost/HtmlHostApp.zip"&gt;Sample Project&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-193477691330602497?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/193477691330602497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=193477691330602497' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/193477691330602497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/193477691330602497'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/03/html-host-control-in-silverlight.html' title='Html Host control in Silverlight'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-8983009365827625664</id><published>2009-03-18T16:38:00.000-07:00</published><updated>2009-04-24T22:15:11.800-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DeepEarth'/><category scheme='http://www.blogger.com/atom/ns#' term='Maps'/><category scheme='http://www.blogger.com/atom/ns#' term='PlaceMarkers'/><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><title type='text'>How to create a simple pushpin as a placemarker for DeepEarth in Silverlight?</title><content type='html'>&lt;span style="font-size:85%;"&gt;  The &lt;a href="http://deepearth.codeplex.com/"&gt;DeepEarth&lt;/a&gt; Maps in codeplex is a very brilliant work and can support a lot of map types with different providers like Yahoo, Open Street Maps, Blue Marble (except Google for now) in silverlight. I am a fan of this work.&lt;br /&gt;&lt;br /&gt;They also have sample source code to create custom push pins. These are like the markers in the javascript version of google and yahoo maps. These are controls derived from a base class called &lt;span style="font-style: italic;"&gt;PointBase &lt;/span&gt;which derives from DependencyObject at the deep base levels. Finally it overrides a function called &lt;span style="font-style: italic;"&gt;OnApplyTemplate &lt;/span&gt;where it really does the work of showing the data/controls. This article does not intend to explain those concepts though.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Problem:&lt;/span&gt;&lt;br /&gt;The sample project they have contains support for Pins which can show JPEG or other items in their styles and ability to show descriptions etc., which is great. But recently I had a requirement just to show the text of a village name for example. The existing sample controls did not fit my needs. So I had to write a simple control on my own. Hope this helps some one else as well.&lt;br /&gt;&lt;br /&gt;Anyway here you go!!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;We need to take care of 2 things. The first is to define a style in App.xaml and the second is to write the control code.&lt;br /&gt;&lt;br /&gt;The control name that I used is "PlaceMarkerPin". You can rename it if you like something else.&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;App.xaml:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;Style x:Key="PlaceMarkerStyle" TargetType="MyControls:PlaceMarkerPin"&amp;gt;&lt;br /&gt;  &amp;lt;Setter Property="Template"&amp;gt;&lt;br /&gt;   &amp;lt;Setter.Value&amp;gt;&lt;br /&gt;    &amp;lt;ControlTemplate TargetType="MyControls:PlaceMarkerPin"&amp;gt;&lt;br /&gt;     &amp;lt;Grid&amp;gt;&lt;br /&gt;      &amp;lt;TextBlock x:Name="DisplayTitle" Text=" " TextAlignment="Center" Foreground="Black" FontSize="12" FontWeight="Bold" /&amp;gt;&lt;br /&gt;     &amp;lt;/Grid&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;/ControlTemplate&amp;gt;&lt;br /&gt;   &amp;lt;/Setter.Value&amp;gt;&lt;br /&gt;  &amp;lt;/Setter&amp;gt;&lt;br /&gt; &amp;lt;/Style&amp;gt;&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;Now if you really look at it we have only one control TextBlock named as "DisplayTitle" in the above style and this is the only item displayed. You can change the Font styles, alignment etc., to your liking.&lt;br /&gt;&lt;br /&gt;Now to the control code&lt;br /&gt;&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;using System.Windows.Browser;&lt;br /&gt;using System.Windows.Controls;&lt;br /&gt;using System.Windows.Input;&lt;br /&gt;using DeepEarth.Geometry;&lt;br /&gt;&lt;br /&gt;namespace YourNameSpace&lt;br /&gt;{&lt;br /&gt;   public class PlaceMarkerPin : PointBase&lt;br /&gt;   {&lt;br /&gt;       private string _title;&lt;br /&gt;&lt;br /&gt;       public string Title&lt;br /&gt;       {&lt;br /&gt;           get { return _title; }&lt;br /&gt;           set { _title = value; }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public PlaceMarkerPin()&lt;br /&gt;       {&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       #region Balloon Functions&lt;br /&gt;&lt;br /&gt;       #endregion&lt;br /&gt;&lt;br /&gt;       public override void OnApplyTemplate()&lt;br /&gt;       {&lt;br /&gt;           TextBlock tbDisplayTitle = (TextBlock)GetTemplateChild("DisplayTitle");&lt;br /&gt;&lt;br /&gt;           bool designTime = (HtmlPage.IsEnabled == false);&lt;br /&gt;           if (designTime == false)&lt;br /&gt;           {&lt;br /&gt;               tbDisplayTitle.Text = _title;&lt;br /&gt;               _IsLoaded = true;&lt;br /&gt;               ForceMeasure();&lt;br /&gt;               Layer.UpdateChildLocation(this);&lt;br /&gt;           }&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       void tbDisplayTitle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)&lt;br /&gt;       {&lt;br /&gt;           CaptureMouse();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;The following is the codesnippet for adding it to the DeepEarth map layer. This assumes that we already have a layer created.&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;Point point = new Point(loc.Longitude, loc.Latitude);&lt;br /&gt;var pin = new PlaceMarkerPin() { Point = point, Style = (Application.Current.Resources["PlaceMarkerStyle"] as Style) };&lt;br /&gt;pin.Title = loc.CustomLocationName;&lt;br /&gt;customlayer.Add(pin);&lt;br /&gt;---------------------------------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;This also is a very short example to actually understand how the pins in DeepEarth Maps work. One can now add more controls and styles to make it better if a need arises.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;                &lt;style key="PlaceMarkerStyle" targettype="VazhikattiMiscControls:PlaceMarkerPin"&gt;&lt;br /&gt;            &lt;setter property="Template"&gt;&lt;br /&gt;                &lt;setter.value&gt;&lt;br /&gt;                    &lt;controltemplate targettype="VazhikattiMiscControls:PlaceMarkerPin"&gt;&lt;br /&gt;                        &lt;grid&gt;&lt;br /&gt;                            &lt;textblock name="DisplayTitle" text=" " textalignment="Center" foreground="Black" fontsize="12" fontweight="Bold"&gt;&lt;br /&gt;                        &lt;/grid&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/controltemplate&gt;&lt;br /&gt;                &lt;/Setter.Value&gt;&lt;br /&gt;            &lt;/setter&gt;&lt;br /&gt;        &lt;/style&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-8983009365827625664?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/8983009365827625664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=8983009365827625664' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/8983009365827625664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/8983009365827625664'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/03/how-to-create-simple-pushpin-as.html' title='How to create a simple pushpin as a placemarker for DeepEarth in Silverlight?'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-7571134055138359128</id><published>2009-02-24T05:08:00.000-08:00</published><updated>2009-02-24T05:14:17.301-08:00</updated><title type='text'>Amazon Elastic IP</title><content type='html'>I started using Amazon Web Service for one of my sites and it is amazingly good in terms of features.&lt;br /&gt;&lt;br /&gt;But the way they have designed the support is very poor. If you are not ready to pay more than $100 for silver support, then you are left to figure everything on your own. They have pretty good documentation but it sometimes does not point you to the right direction.&lt;br /&gt;&lt;br /&gt;Well enough of Fluff.. &lt;span style="font-weight:bold;"&gt;I had a problem that I did not know how to connect to a particular port using the Elastic IP&lt;/span&gt;. I searched everywhere and finally figured out myself.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;There is a section called "Security Group" and we have to enable the port for the group we have used during creating the instance.&lt;/span&gt; It took me a couple of lost days to figure this out!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-7571134055138359128?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/7571134055138359128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=7571134055138359128' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7571134055138359128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/7571134055138359128'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/02/amazon-elastic-ip.html' title='Amazon Elastic IP'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-6235329358711217952</id><published>2009-01-10T16:23:00.000-08:00</published><updated>2009-01-10T17:19:25.340-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Silverlight'/><category scheme='http://www.blogger.com/atom/ns#' term='Datagrid'/><title type='text'>Silverlight Datagrid find row number</title><content type='html'>Silverlight 2.0 datagrid has rich UI features giving very impressive look and feel. I am trying to add to a list of difficult to find tricks which might be helpful to others. I could not obviously find these while I did the google search, so I am writing this now.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Adding a button column to Silverlight Grid:&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&amp;lt;data:datagrid name="gridCustomers" autogeneratecolumns="False" headersvisibility="All" gridlinesvisibility="All" isreadonly="True" rowbackground="Cornsilk" alternatingrowbackground="LemonChiffon"&lt;br /&gt;ColumnWidth="85" RowHeight="30" CanUserResizeColumns="False" Canvas.Top="603" Canvas.Left="16" Width="1072" Height="120" SelectionMode="Single"  &amp;gt;&lt;br /&gt;&amp;lt;data:datagrid.columns&amp;gt;&lt;br /&gt;&amp;lt;data:datagridtextcolumn header="Id" binding="{Binding id}"&amp;gt;&lt;br /&gt;&amp;lt;data:datagridtextcolumn header="Location Name" binding="{Binding Name}"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&amp;lt;data:datagridtemplatecolumn header="Edit"&amp;gt;&lt;br /&gt;&amp;lt;data:datagridtemplatecolumn.celltemplate&amp;gt;&lt;br /&gt;&amp;lt;datatemplate&amp;gt;&lt;br /&gt;&amp;lt;button content="Edit" margin="4" tag="{Binding customlocationid}" click="datagridEditRow_Click"&amp;gt;&amp;lt;/button&amp;gt;&lt;br /&gt;&amp;lt;/datatemplate&amp;gt;&lt;br /&gt;&amp;lt;/data:DataGridTemplateColumn.CellTemplate&amp;gt;&lt;br /&gt;&amp;lt;/data:DataGridTemplateColumn&amp;gt;&lt;br /&gt;&amp;lt;data:datagridtemplatecolumn header=""&amp;gt;&lt;br /&gt;&amp;lt;data:datagridtemplatecolumn.celltemplate&amp;gt;&lt;br /&gt;&amp;lt;datatemplate&amp;gt;&lt;br /&gt;&amp;lt;button content="Delete" margin="4" tag="{Binding customlocationid}" click="datagridDeleteRow_Click"&amp;gt;&amp;lt;/button&gt;&lt;br /&gt;&amp;lt;/datatemplate&amp;gt;&lt;br /&gt;&amp;lt;/data:DataGridTemplateColumn.CellTemplate&amp;gt;&lt;br /&gt;&amp;lt;/data:DataGridTemplateColumn&amp;gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;The above code gives the WPF markup for the grid. See the &lt;span style="font-weight:bold;"&gt;bold&lt;/span&gt; font for the Templated Column definitions for the "Edit" and "Delete" buttons.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Finding the row numbers:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;  Now our button click event handlers &lt;span class="Apple-style-span" style="font-style: italic;"&gt;datagridEditRow_Click&lt;/span&gt; and &lt;span class="Apple-style-span" style="font-style: italic;"&gt;datagridDeleteRow_Click&lt;/span&gt; will need to know the row numbers when they are clicked. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  We cannot use the gridCustomers.SelectedItem for this. The reason is, a click on the button won't automatically select the row. So we have to use the following code.&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        private void datagridEditRow_Click(object sender, RoutedEventArgs e)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;            Button btnSender = (Button)e.OriginalSource;&lt;/div&gt;&lt;div&gt;            int dgridrow = DataGridRow.GetRowContainingElement(btnSender).GetIndex();&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;            gridLocations.SelectedIndex = dgridrow;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;      }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; The above code will automatically get us the row number and we can use it to find the data in the row or may be select that row by setting the selectedindex property.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-6235329358711217952?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/6235329358711217952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=6235329358711217952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/6235329358711217952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/6235329358711217952'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2009/01/silverlight-datagrid-find-row-number.html' title='Silverlight Datagrid find row number'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-4674623464405729180</id><published>2008-12-25T04:31:00.000-08:00</published><updated>2008-12-25T04:35:15.798-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Error'/><category scheme='http://www.blogger.com/atom/ns#' term='Sql 2008'/><title type='text'>Sql Server 2008 Error Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)</title><content type='html'>Very strange. I was trying to attach a database using my 'sa' account which was detached before with some other account. I got this error.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;-----------------------------------------------------------------------------------------&lt;/div&gt;&lt;div&gt;&lt;div&gt;TITLE: Microsoft SQL Server Management Studio&lt;/div&gt;&lt;div&gt;------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;amp;LinkId=20476&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;------------------------------&lt;/div&gt;&lt;div&gt;ADDITIONAL INFORMATION:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file  (Microsoft SQL Server, Error: 5123)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&amp;amp;ProdVer=10.00.1600&amp;amp;EvtSrc=MSSQLServer&amp;amp;EvtID=5123&amp;amp;LinkId=20476&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;------------------------------&lt;/div&gt;&lt;div&gt;BUTTONS:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;OK&lt;/div&gt;&lt;div&gt;------------------------------&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, I opened another instance of SQL Management studio and used my regular windows authenticated account to attach and it worked magically.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I understood the reason after it. Basically the 'sa' account is the Sql server account which need not have access to my File system. So it is obvious !&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-4674623464405729180?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/4674623464405729180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=4674623464405729180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/4674623464405729180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/4674623464405729180'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2008/12/sql-server-2008-error-failed-to.html' title='Sql Server 2008 Error Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-6478299679980935012</id><published>2008-12-24T23:49:00.000-08:00</published><updated>2008-12-25T04:35:54.140-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='LINQ'/><title type='text'>Small compile time error on LINQ (Could not find an implementation of the query pattern for source type . 'Select' not found)</title><content type='html'>A very verysilly error with LINQ. Happens when you try to use technology without learning it properly (obviously that's what happened to me).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The error you receive "&lt;span class="Apple-style-span" style="font-family: Arial; font-size: 13px; white-space: pre; "&gt;Could not find an implementation of the query pattern for source type . 'Select' not found."&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I was trying to use a LINQ query like this&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;var query = from w in TableName&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(204, 0, 0);"&gt;      select w;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The above gave the error and I could not find a search result properly. Obviously people would have realized their mistakes, so wouldn't have posted it. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The actual error is because we should not use the type name, rather we should be using the table instance variable in the datacontext. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So after changing the query to&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;var query = from w in DataContext.TableInstanceName&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;      select w;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;the problem is solved.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-6478299679980935012?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/6478299679980935012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=6478299679980935012' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/6478299679980935012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/6478299679980935012'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2008/12/small-compile-time-error-on-linq-could.html' title='Small compile time error on LINQ (Could not find an implementation of the query pattern for source type . &apos;Select&apos; not found)'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-8747821126084800237</id><published>2008-12-24T02:41:00.000-08:00</published><updated>2008-12-25T05:14:48.979-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql 2008'/><title type='text'>Sql Server Cannot open user default database. Login failed</title><content type='html'>&lt;div&gt;This may help a few people. I was trying to connect to SQL Server 2008 from my VS 2008 and suddenly it could not list any databases from my server. I had Enterprise edition. I believe the same problems can occur in any versions of SQL Server be it Express, Standard or WorkGroup editions.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The exact error message was &lt;span class="Apple-style-span" style="font-family: arial; font-size: 13px; "&gt;&lt;em style="font-weight: bold; font-style: normal; text-decoration: inherit; "&gt;Cannot open user default database&lt;/em&gt;. &lt;em style="font-weight: bold; font-style: normal; text-decoration: inherit; "&gt;Login failed&lt;/em&gt;. &lt;em style="font-weight: bold; font-style: normal; text-decoration: inherit; "&gt;Login failed&lt;/em&gt; for &lt;em style="font-weight: bold; font-style: normal; text-decoration: inherit; "&gt;user '' , Error Number 4064.&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After a lot of google search which could not actually point to my actual problems, I found it myself.&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_e-y2oeuQDfU/SVIS3LtuzBI/AAAAAAAAALw/egbBE-MXdp4/s1600-h/Sql2008Login.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 287px;" src="http://3.bp.blogspot.com/_e-y2oeuQDfU/SVIS3LtuzBI/AAAAAAAAALw/egbBE-MXdp4/s320/Sql2008Login.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5283306052105718802" /&gt;&lt;/a&gt; We basically&lt;span class="Apple-style-span" style="font-weight: bold;"&gt; need to specify the default database for the user login&lt;/span&gt;. If not, then we won't be able to login. &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;  But one problem here is that we need some other account either "sa" or some other admin account to change this setting. This setting is found at Sql Management Studio --&gt; Security --&gt; Logins --&gt; Double click on the user name..&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; Hope someone finds this useful.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-8747821126084800237?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/8747821126084800237/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=8747821126084800237' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/8747821126084800237'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/8747821126084800237'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2008/12/sql-server-cannot-open-user-default.html' title='Sql Server Cannot open user default database. Login failed'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_e-y2oeuQDfU/SVIS3LtuzBI/AAAAAAAAALw/egbBE-MXdp4/s72-c/Sql2008Login.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7178878378157985534.post-3100838558903015972</id><published>2008-02-21T16:54:00.000-08:00</published><updated>2008-02-21T17:11:57.576-08:00</updated><title type='text'>Encapsulation or Law of demeter</title><content type='html'>When I was designing a C# class to do some work, I had a design choice to choose between a dictionary to be returned or not from a Utility class. My requirement was that I needed a dictionary to be used wherever this Utility.Function class is called. I found an nice and interesting article by Thomas Johansson at &lt;a href="http://tomas.oo-systemutvecklare.se/articles/encapsulation.php"&gt;http://tomas.oo-systemutvecklare.se/articles/encapsulation.php&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;Law of Demeter&lt;/span&gt; as defined in Wikipedia suggests that a Method say &lt;span style="font-weight: bold;"&gt;M&lt;/span&gt; of an Object &lt;span style="font-weight: bold;"&gt;obj&lt;/span&gt; will have access to only the following.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The object obj&lt;/li&gt;&lt;li&gt;Method's parameters&lt;/li&gt;&lt;li&gt;The fields of the object&lt;/li&gt;&lt;li&gt;The variables declared inside the method&lt;/li&gt;&lt;/ol&gt;Reflecting on what could be the advantages of the approach, let us assume that we have a File maintenance project in which we keep a List&lt;string&gt; and we allow all others to modify this field freely.&lt;br /&gt;&lt;br /&gt;public class MyNonEncapsulatedClass&lt;br /&gt;{&lt;br /&gt;   public List&lt;string&gt; stringvalues;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;This obviously leads to a dependency issue. If I want to now convert this class to use a Dictionary&lt;int,&gt; because it offers some additional advantages, then we have a problem. Had we kept this as a private field with only the object's functions modifying it, we can choose to return the old type without breaking any code which depends on this.&lt;br /&gt;&lt;br /&gt;public class MyNonEncapsulatedClass&lt;br /&gt;{&lt;br /&gt;   private Dictionary&lt;int,&gt; stringvaluesDictionary;&lt;br /&gt;  &lt;br /&gt;   public List&lt;string&gt; ReturnList()&lt;br /&gt;   {&lt;br /&gt;      return new List&lt;string&gt;(stringvaluesDictionary.Values);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Ofcourse there is other option of using immutable keyword.&lt;br /&gt;&lt;br /&gt;Any comments?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7178878378157985534-3100838558903015972?l=csharp-snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-snippets.blogspot.com/feeds/3100838558903015972/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7178878378157985534&amp;postID=3100838558903015972' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/3100838558903015972'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7178878378157985534/posts/default/3100838558903015972'/><link rel='alternate' type='text/html' href='http://csharp-snippets.blogspot.com/2008/02/encapsulation-or-law-of-demeter.html' title='Encapsulation or Law of demeter'/><author><name>muthu.v</name><uri>http://www.blogger.com/profile/15358837957522166128</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
