tag:blogger.com,1999:blog-44912552363110471222024-02-21T00:58:26.540-08:00Dot + Net <=> Digging .NetAll about HTML, CSS, Javascript, JQuery, Silverlight, WPF, WCF, LINQ, SQLKranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-4491255236311047122.post-76803264123891529302010-09-29T13:15:00.000-07:002010-09-29T13:36:14.120-07:00How To : Host Silverlight Xap in Blogger<b>Hositing Silverlight XAP in Blogger... Aah At last succeded.. Yipeee</b><br />
<br />
I was trying to host silverlight application in blogger from the past two weeks and at last succeded today :) as you can see below.<br />
<br />
<script src="http://xthkranthi.xtreemhost.com/Silverlight.js" type="text/javascript">
</script><br />
<div id="silverlightControlHost" style="height: 100px; margin: 0 auto; width: 100px;"><object data="data:application/x-silverlight-2," height="100%" type="application/x-silverlight-2" width="100%"> <param name="source" value="http://xthkranthi.xtreemhost.com/Test.xap"/><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="minRuntimeVersion" value="4.0.50401.0" /><param name="autoUpgrade" value="true" /><param name="enableHtmlAccess" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="border: 0px; height: 0px; visibility: hidden; width: 0px;"></iframe></div><br />
When i first googled, i found this wonderful <a href="http://timheuer.com/blog/archive/2010/06/10/troubleshooting-debugging-silverlight-cross-domain-xap-hosting.aspx" target="_blank">post</a> of timheuer which explains about cross-domain hositing of silverlight application in detail.<br />
<br />
The big question which i had after reading tim's blog post is, where do i host my xap file as i need to set the XAP mime type on the hosting server, I personally do not own any hosting space nor any domain. <br />
In the next moment i started searching for free file hosting providers, which can provide me a direct link for hosted file with file extension so that i can refer to the xap file directly. I tried around 5 different file hosting servers but i couldn't figure out how to set the mime extension type on that perticular server to render my silverlight xap on my blogger blog. <br />
<br />
In my 6th attempt to host xap, i have tried with <a href="http://xtreemhost.com/">xtreemhost</a> file hosting which has not only provided me with a direct link to the hosted file but also provided access to the .htaccess file where i could add my MIME types.<br />
<br />
So here are few things which we need to take care before hosting a silverlight application on to blog:<br />
<br />
<ul><li>Make sure you have added the <b>EnableHtmlAcces</b>s parameter to the object tag in html<br />
<pre name="code" class="xml"><param name="enableHtmlAccess" value="true" /></pre></li>
<li>Make sure you have set <b>ExternalCallersFromCrossDomain </b>to <b>ScriptableOnly</b> in the AppManifest.xml file in silverlight project<br />
<pre name="code" class="xml"><Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ExternalCallersFromCrossDomain="ScriptableOnly">
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
</pre></li>
<li>Add the MIME types on the hosting server(if not added already :)).<br />
On XtreemHost this is how i added the MIME types, In the /htdocs directory i have created a new file with name .htaccess and added the below mentioned two lines in the .htaccess file<br />
<pre name="code" class="xml">AddType application/x-silverlight-app .xap
AddType application/xaml+xml .xaml</pre></li>
</ul><br />
Here onwards everything should be straight-forward and simple, upload your xap file on to the file hosting server and set the source value in the object tag to the hosted xap file, below is the object tag for the above rendered silverlight application<br />
<br />
<pre name="code" class="xml"><script type="text/javascript" src="http://xthkranthi.xtreemhost.com/Silverlight.js"></script>
<div id="silverlightControlHost" Style="height:100px;width:100px;">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="http://xthkranthi.xtreemhost.com/Test.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<param name="enableHtmlAccess" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/> </a> </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>
</pre><br />
Done.. That should do it!!!! If nothing went wrong then your silverlight application should be on you blog as mine :).<br />
<br />
Hope this helps someone.. comments are always welcome and please let me know if you have any issues in loading silverlight applicaiton on your blog.Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com5tag:blogger.com,1999:blog-4491255236311047122.post-69102711070471534702010-09-15T02:11:00.000-07:002010-10-26T10:44:30.175-07:00Workaround for showing a tooltip for disabled control in silverlightIn WPF we have ShowOnDisabled property for ToolTipService, which displays the tooltip even the control is in the disabled state. Intrestingly, i have'nt found this property in silverlight and need to implement this in silvelright.<br />
<br />
On googling a bit i found <a href="http://forums.silverlight.net/forums/t/52753.aspx">this</a> post in silverlight fourms which says <br />
"Having the ToolTip not show on a disabled element is by design, and compatible with WPF. We realize that Silverlight lacks other means to provide ToolTips on disabled items (such as ToolTipService.ShowOnDisabled), and will be looking into it." as is.<br />
<br />
Here is the workaround which i found while implementing this functionalty.<br />
<pre class="c-sharp" name="code"><Border HorizontalAlignment="Center" VerticalAlignment="Center" Background="Transparent" >
<ToolTipService.ToolTip>
<ToolTip Content="Tool Tip"/>
</ToolTipService.ToolTip>
<Button x:Name="button" Width="75" Content="Button" IsEnabled="False" />
</Border>
</pre><br />
My first thought to show the tooltip, was to wrap the control (Button) inside another control (Border) and add the tooltip to the parent (Border) control. As we will enable and disable the child control, parent control displays the tooltip.<br />
<br />
<strike>Unfortunately this did not work. When Button is disabled, Border control is not showing up the tooltip. My guess was Border control is not able to find its child controls when they are disabled, then i tried placing a rectangle with 0.1 opacity beneath the button, which makes sure that border has content irrespective of the enabled state of the button.</strike><br />
<br />
[<b>Updating post</b> as some of my friends suggested a better solution, and the good thing was my first thought was not wrong, just making wrapper control (Border) background to transparent is enough.. which works like a charm.. i've updated the code snippet accordingly..]<br />
<br />
This was my workaround, If anyone finds a better way please post a comment with that solution. As that may help somebody like me :).<br />
<br />
Hope this post helps some one.Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com3tag:blogger.com,1999:blog-4491255236311047122.post-52757718660608061242010-09-09T12:16:00.000-07:002010-09-14T10:55:32.947-07:00How To : Load Multiple XAP files in Silverlight ApplicationCurrently i am working on a project where i had a requirement to load multiple xap files in a silverlight application, or let me keep this way i need to load xap files OnDemand. <br />
I was going through <a href="http://msdn.microsoft.com/en-us/library/cc903931(VS.95).aspx" target="_blank">this</a> article on msdn where it explains about "how to load assemblies on demand", before reading this article i really had no idea of how to load multiple xap files, but now i have done that yipee... :) <br />
I just want to blog a bit about how to load multiple xap files in silvelright application, and also share some sample application which demonstrates this. As usual you can find the source code the end of this blog post.<br />
<br />
To get started with this sample i've created a silverlight project and added two silverlight class libraries, now my solution looks as shown below<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzA9dUoFzxv9xIuwqdYGyAjoI_XEjurUgVLAeDJ7wRpOzW4684lXf2MnKeOZPpjo-PkTqZeSx2jVlO6Daq6urtLiP2rkaribSj0vpHnwHbxKfZtFYDfSUZbvgRCntUyiRss3JDRaJPlgc/s1600/MultipleXapLoader_Sln.PNG" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;" target="_blank"><img border="0" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzA9dUoFzxv9xIuwqdYGyAjoI_XEjurUgVLAeDJ7wRpOzW4684lXf2MnKeOZPpjo-PkTqZeSx2jVlO6Daq6urtLiP2rkaribSj0vpHnwHbxKfZtFYDfSUZbvgRCntUyiRss3JDRaJPlgc/s320/MultipleXapLoader_Sln.PNG" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
First let us check out how to load a single xap file, the below code shows how to read a xap file and read the dll file for the perticular class for which we want to create the instance and returns that perticular instance.<br />
The Things to check out in the below code snippet are the two private variables:<br />
<ul><li>applicationName - The name of the xap file with out extension.</li>
<li>control - The class in the above mentioned application for which you want to create instance.</li>
</ul><pre class="csharp" name="code">public partial class MainPage : UserControl
{
string applicationName = "SilverlightApplication1";
string control = "Control";
public MainPage()
{
InitializeComponent();
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(new Uri("SilverlightApplication1.xap", UriKind.Relative));
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
StreamResourceInfo resourceInfoDLL = Application.GetResourceStream(new StreamResourceInfo(e.Result, null),
new Uri(string.Format("{0}.dll", applicationName), UriKind.Relative));
AssemblyPart assemblyPart = new AssemblyPart();
Assembly assembly = assemblyPart.Load(resourceInfoDLL.Stream);
UIElement element = assembly.CreateInstance(string.Format("{0}.{1}", applicationName, control)) as UIElement;
LayoutRoot.Children.Add(element);
}
}
</pre>Using the webclient we can read the xap file and load its content in the silverlight applicaiton as shown above, I have added the "<strong>Control</strong>" instance, which is a user control in <strong>SilverlightApplication1</strong> project to the <strong>LayoutRoot</strong>, which is a grid in our <strong>Main Silverlight application</strong>.<br />
If we want to load multiple xaps then we need to create multiple instances of webclient and load xap files, The final output of the shared source code would look like the below image.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRW87lsh5zO0JTjAJs4CzdwUPVCyhuqwMeRn830Ca51op0H9RG1oXvkQCor8zLyppnx1HymgA4D4XSkP4lFyT4cjawDwzxeMqgtC-f0Hkz5zvt7cui7wCxBMql96Cy97Sb3GrxJ2I0QHc/s1600/MultipleXapLoader_op.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRW87lsh5zO0JTjAJs4CzdwUPVCyhuqwMeRn830Ca51op0H9RG1oXvkQCor8zLyppnx1HymgA4D4XSkP4lFyT4cjawDwzxeMqgtC-f0Hkz5zvt7cui7wCxBMql96Cy97Sb3GrxJ2I0QHc/s320/MultipleXapLoader_op.PNG" /></a></div>At last here is the <a href="https://docs.google.com/leaf?id=0B6zEK6RhNaOZMGQzZjAwMjctYmYzOS00NDA5LWIyYzQtZWE3MjcxMTYxMGRm&hl=en&authkey=CN3gqfEI" target="_blank">Source Code</a> for this particular blog post, to load xap files ondemand.<br />
Hope this post helps some one in need... :)Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com2tag:blogger.com,1999:blog-4491255236311047122.post-19445019593591054252010-08-30T12:33:00.000-07:002010-09-29T02:14:39.949-07:00How To : Communicate between two user-controls using Event AggregatorI found many posts in the asp.net, silverlight.net fourms regarding communication between user-controls, so i thought to blog a bit about communication between user-controls using <b>Event Aggregator</b> in silverlight which i found is the best way to communicate.<br />
<br />
The main advantage for using an event aggregator to communicate between user-controls is, it removes the tight coupling between a publisher and a subscriber, by which a publisher/subscriber can evolve independently. Pre-requisites for understanding this blog post is to have a bit understanding of <a href="http://msdn.microsoft.com/en-us/library/ff647984.aspx" target="_blank">Event Aggregator</a>.<br />
<br />
<strong>Live Demo </strong>: <a target="_blank" href="http://kranthigullapalli.awardspace.biz/EventAggregatorSample.html">Event Aggregator Sample</a><br />
<strong>Source Code</strong>: At the end of this post :).<br />
<br />
In this post i will explain how two user-controls can pass messages between them using event aggregator, consider a simple chat scenario where one user types-in some message and sends to to another user and vice-versa. My Visual Studio Solution looks as shown below, things to observe are<br />
<ul><li>Microsoft Practices Composite dll's which are required for implementing the event aggregation</li>
<li><a href="https://docs.google.com/leaf?id=0B6zEK6RhNaOZZGY3MGVlYTAtMDdlMi00MWQ5LWFhMDAtZjIwMTQ1ZWZkMzUy&hl=en&authkey=CNez79EH" target="_blank">EventAggregator.cs</a> which implements the interface IEventAggregator. (Note: will share the enitre source code at the end of this blog post :) )</li>
<li>"<b>Kranthi.xaml</b>" and "<b>Kiran.xaml</b>", two user controls which communicate using event aggregator. </li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW5gC6SfzCH17obJ2pH-EHstDxIvh2poRKGPak_f2zQ4fPfp-4fQjg924MH4l-kFKg1ZLfl4qvYG9Pk2rvbqsj_hx76zBaW2piZSRf2WToMmDSjqP4CzxVBG6JhNONpZev7U2gRHjsDQ/s1600/SolutionView.PNG" target="_blank" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRW5gC6SfzCH17obJ2pH-EHstDxIvh2poRKGPak_f2zQ4fPfp-4fQjg924MH4l-kFKg1ZLfl4qvYG9Pk2rvbqsj_hx76zBaW2piZSRf2WToMmDSjqP4CzxVBG6JhNONpZev7U2gRHjsDQ/s320/SolutionView.PNG" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Both the user controls have same functionality to implement. Lets see how the "Kranthi.xaml" user-control UI is likely to be, it contains following:<br />
<ul><li>Text Box, where user enters message to publish.</li>
<li>Button, used to publish the entered message in TextBox.</li>
<li>ListBox, to display the received messages from the subscribed event. </li>
</ul>"Kiran.xaml" user-control also has the same controls, so now i am ready with a sample user-interface which looks like below<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbPf_9xoJT67ZoZO3x166puoCWjo9njMKXMDqIiIBksYAnXwMJpaLyxlhgTR07_c-dB9q4sDXpLFX9mGNqknagjQxUg7K8-Q63PdTT74hZiFPo1tJAlN4JUKjQUbfirFVSBhcGISz2RWw/s1600/UserInterface.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="176" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbPf_9xoJT67ZoZO3x166puoCWjo9njMKXMDqIiIBksYAnXwMJpaLyxlhgTR07_c-dB9q4sDXpLFX9mGNqknagjQxUg7K8-Q63PdTT74hZiFPo1tJAlN4JUKjQUbfirFVSBhcGISz2RWw/s400/UserInterface.PNG" width="400" target="_blank" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
So now i am defining two events to communicate <br />
<ol><li><b>MessageToKiran </b>event is published by "Kranthi.xaml" and is subscribed by "Kiran.xaml". </li>
<li><b>MessageToKranthi </b>event is published by "Kiran.xaml" and is subscribed by "Kranthi.xaml".</li>
</ol>Whenever an event is published, all the subscribers for that event get notified regarding the published message.<br />
<pre class="csharp" name="code">namespace EventAggregationSample
{
public class MessageToKranthi : PresentationEvent<string> { }
public class MessageToKiran : PresentationEvent<string> { }
}</pre><b>Subscribing to Event:</b><br />
Before subscribing or publishing a message, we need to instantiate EventAggregator and Subscribe to event as shown below<br />
<pre class="csharp" name="code">IEventAggregator Aggregator { get; set; }
//Constructor
public Kranthi()
{
InitializeComponent();
Aggregator = new EventAggregator();
Aggregator.Subscribe<MessageToKranthi, string>(OnMessageToKiran);
}
public void OnMessageToKiran(PresentationEvent<string> e)
{
ListBoxItem item = new ListBoxItem();
item.Content = e.Payload;
lbMessages.Items.Add(item);
}
</pre>In the Constructor, I've initialized the Aggregator and subscribed to the event MessageToKranthi, which has a payload of type string(which is our message). Whenever any user-control publishes MessageToKranthi event then "OnMessageToKiran" code gets executed.<br />
<br />
<b>Publishing an Event:</b><br />
We can use event aggregator to send message for all subscribers of that event as below<br />
<pre class="csharp" name="code">Aggregator.SendMessage<MessageToKiran, string>(
new MessageToKiran { Payload = tbMessage.Text }
);
</pre>The above code publishes "MessageToKiran" event with the payload of the user entered text, this text is passed as payload to all the subscribers for this event.<br />
<br />
To Complete the Communication, two user-controls should perform the following activities<br />
<ul><li>Kranthi.xaml - Publish the event "MessageToKiran" and Subscribe for the event "MessageToKranthi"</li>
<li>Kiran.xaml - Publish the event "MessageToKranthi" and Subscribe for the event "MessageToKiran"</li>
</ul>Finally here is the <a href="https://docs.google.com/leaf?id=0B6zEK6RhNaOZOWYzY2JiYjgtMDc1Yy00MjRmLWEzZDktMDk2NzMzYzMyODdi&hl=en&authkey=CPSR2KII" target="_blank">link</a> for the source code which demonstrates the event aggregation sample. hope this helps someone.. :)Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com6tag:blogger.com,1999:blog-4491255236311047122.post-80714621498597038402010-08-29T22:49:00.000-07:002010-09-29T23:01:57.487-07:00How To : Publish Code Snippets in Blog in 3 StepsMost of my posts in my blog are related to .NET technology, as i am a .NET developer. One of the most frequent question for a developer who has just started to blog is "How to publish code snippet in blog". I too had the same question and after googling a bit and found couple of articles which i found useful, i just want to gather all useful stuff togather as explained below.<br />
<br />
Login to your <b>Blogger Account</b> and Click on <b>Design </b>link and Click on <b>Edit HTML</b>, which is highlighted in the image shown below.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZMUGkzd74zYP19gnHKo17DmHkh17tL-ObXLkD8WuEzwk715bz9PA-S_rVWweioYbxDwevEObu_p9OBnKO1HjbdnPzkjHntYf1cFWi8VuuRgKrUeFGs9NRZkIT1S5khHkVpNbpKF6hXgI/s1600/EditBloggerHtml.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="81" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZMUGkzd74zYP19gnHKo17DmHkh17tL-ObXLkD8WuEzwk715bz9PA-S_rVWweioYbxDwevEObu_p9OBnKO1HjbdnPzkjHntYf1cFWi8VuuRgKrUeFGs9NRZkIT1S5khHkVpNbpKF6hXgI/s320/EditBloggerHtml.PNG" width="320" /></a></div><br />
<br />
<br />
<br />
<br />
Now follow these simple 3 steps to publish code snippets in blogger:<br />
<br />
<ol><li>Search for "/head" in the HTML template and paste the below script tags <b>above</b> that. [Note]: Check "Expand Widget Templates" if search result is not found<br />
<br />
<br />
<pre class="javascript" name="code"><script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js' type='text/javascript'/>
</pre></li>
<li>Search for "/body" and Paste the below javascript code <b>above</b> "/body"<br />
<br />
<br />
<pre class="javascript" name="code"><script language="javascript">
dp.SyntaxHighlighter.BloggerMode();
dp.SyntaxHighlighter.HighlightAll('code');
</script>
</pre></li>
<li>Paste the below CSS code <b>before</b> "]]></b:skin>" in your HTML Template<br />
<br />
<br />
<pre class="css" name="code">.dp-highlighter
{
font-family: "Consolas", "Monaco", "Courier New", Courier, monospace;
font-size: 12px;
background-color: #E7E5DC;
width: 99%;
overflow: auto;
margin: 18px 0 18px 0 !important;
padding-top: 1px; /* adds a little border on top when controls are hidden */
}
/* clear styles */
.dp-highlighter ol,
.dp-highlighter ol li,
.dp-highlighter ol li span
{
margin: 0;
padding: 0;
border: none;
}
.dp-highlighter a,
.dp-highlighter a:hover
{
background: none;
border: none;
padding: 0;
margin: 0;
}
.dp-highlighter .bar
{
padding-left: 45px;
}
.dp-highlighter.collapsed .bar,
.dp-highlighter.nogutter .bar
{
padding-left: 0px;
}
.dp-highlighter ol
{
list-style: decimal; /* for ie */
background-color: #fff;
margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */
padding: 0px;
color: #5C5C5C;
}
.dp-highlighter.nogutter ol,
.dp-highlighter.nogutter ol li
{
list-style: none !important;
margin-left: 0px !important;
}
.dp-highlighter ol li,
.dp-highlighter .columns div
{
list-style: decimal-leading-zero; /* better look for others, override cascade from OL */
list-style-position: outside !important;
border-left: 3px solid #6CE26C;
background-color: #F8F8F8;
color: #5C5C5C;
padding: 0 3px 0 10px !important;
margin: 0 !important;
line-height: 14px;
}
.dp-highlighter.nogutter ol li,
.dp-highlighter.nogutter .columns div
{
border: 0;
}
.dp-highlighter .columns
{
background-color: #F8F8F8;
color: gray;
overflow: hidden;
width: 100%;
}
.dp-highlighter .columns div
{
padding-bottom: 5px;
}
.dp-highlighter ol li.alt
{
background-color: #FFF;
color: inherit;
}
.dp-highlighter ol li span
{
color: black;
background-color: inherit;
}
/* Adjust some properties when collapsed */
.dp-highlighter.collapsed ol
{
margin: 0px;
}
.dp-highlighter.collapsed ol li
{
display: none;
}
/* Additional modifications when in print-view */
.dp-highlighter.printing
{
border: none;
}
.dp-highlighter.printing .tools
{
display: none !important;
}
.dp-highlighter.printing li
{
display: list-item !important;
}
/* Styles for the tools */
.dp-highlighter .tools
{
padding: 3px 8px 3px 10px;
font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
color: silver;
background-color: #f8f8f8;
padding-bottom: 10px;
border-left: 3px solid #6CE26C;
}
.dp-highlighter.nogutter .tools
{
border-left: 0;
}
.dp-highlighter.collapsed .tools
{
border-bottom: 0;
}
.dp-highlighter .tools a
{
font-size: 9px;
color: #a0a0a0;
background-color: inherit;
text-decoration: none;
margin-right: 10px;
}
.dp-highlighter .tools a:hover
{
color: red;
background-color: inherit;
text-decoration: underline;
}
/* About dialog styles */
.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; }
.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; }
.dp-about td { padding: 10px; vertical-align: top; }
.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; }
.dp-about .title { color: red; background-color: inherit; font-weight: bold; }
.dp-about .para { margin: 0 0 4px 0; }
.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; }
.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; }
/* Language specific styles */
.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; }
.dp-highlighter .string { color: blue; background-color: inherit; }
.dp-highlighter .keyword { color: #069; font-weight: bold; background-color: inherit; }
.dp-highlighter .preprocessor { color: gray; background-color: inherit; }
</pre></li>
</ol><br />
Done!!!! :) Those were the changes to be made in the HTML Template and now you can start posting your source code in blogger as shown below:<br />
While writing a post, select "Edit HTML" to write the blog post in html mode and wrap your source code snippet with a pre tag and add name="code" and class="<your source code language>", after wrapping your source code it should look like something below<br />
<pre class="csharp" name="code"><pre name="code" class="csharp">
//your source code goes here
</pre>
</pre><br />
Here is the list of supported languages, shamelessly copied from <a href="http://code.google.com/p/syntaxhighlighter/wiki/Languages">here</a>:<br />
<br />
<table style="border-collapse: separate; font-family: arial, sans-serif; font-size: 13px;"><tbody>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><strong>Language</strong></td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><strong>Aliases</strong></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">C++</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">cpp</tt>, <tt style="font-size: 13px;">c</tt>, <tt style="font-size: 13px;">c++</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">C#</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">c#</tt>, <tt style="font-size: 13px;">c-sharp</tt>, <tt style="font-size: 13px;">csharp</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">CSS</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">css</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Delphi</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">delphi</tt>, <tt style="font-size: 13px;">pascal</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Java</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">java</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Java Script</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">js</tt>, <tt style="font-size: 13px;">jscript</tt>, <tt style="font-size: 13px;">javascript</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">PHP</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">php</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Python</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">py</tt>, <tt style="font-size: 13px;">python</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Ruby</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">rb</tt>, <tt style="font-size: 13px;">ruby</tt>, <tt style="font-size: 13px;">rails</tt>, <tt style="font-size: 13px;">ror</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">Sql</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">sql</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">VB</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">vb</tt>, <tt style="font-size: 13px;">vb.net</tt></td></tr>
<tr><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;">XML/HTML</td><td style="border-bottom-color: rgb(170, 170, 170); border-bottom-style: solid; border-bottom-width: 1px; border-left-color: rgb(170, 170, 170); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(170, 170, 170); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(170, 170, 170); border-top-style: solid; border-top-width: 1px; font-size: 13px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;"><tt style="font-size: 13px;">xml</tt>, <tt style="font-size: 13px;">html</tt>, <tt style="font-size: 13px;">xhtml</tt>, <tt style="font-size: 13px;">xslt</tt></td></tr>
</tbody></table><br />
Hope this helps someone :)<br />
<br />
References/Useful Links:<br />
<a href="http://urenjoy.blogspot.com/2008/10/publish-source-code-in-blogger.html">http://urenjoy.blogspot.com/2008/10/publish-source-code-in-blogger.html</a><br />
<a href="http://pleasemakeanote.blogspot.com/2008/06/posting-source-code-in-blogger.html">http://pleasemakeanote.blogspot.com/2008/06/posting-source-code-in-blogger.html</a>Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com1tag:blogger.com,1999:blog-4491255236311047122.post-40945664111484481632010-08-23T07:03:00.000-07:002010-09-14T10:54:33.565-07:00The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.I was working on entity framework to access the underlying data using data access layer. I've added EDMX file, generated the required entity classes and was ready to go.<br />
<br />
When i ran the application, i have encountered with "<b>The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.</b>" error. I was really confused, as I have not modified the connection string manually. Entity framework generated edmx file and updated the webconfig file with the connection string.<br />
<br />
After spending a good amount of time on this issue, i found out the solution for this issue and is explained below:<br />
<br />
<b>Problem:</b> The created entity model .edmx file is in a class library project which i have created for accessing the data and the connection string is generated in the web.config file in the same class library project. When the application is running, the application checks for the connection string in the web.config file residing in the website project and it is not able to find there. This is the cause for the issue.<br />
<br />
<b>Solution:</b> M<b>oving the connection string from newly created class library project to the website projec</b>t.<br />
Hope this helps someone. :)Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com0tag:blogger.com,1999:blog-4491255236311047122.post-70725734342951409892010-08-11T07:10:00.000-07:002010-09-14T10:55:32.948-07:00Message: Failed to download a platform extension: System.ComponentModel.DataAnnotations.zipI was trying to reduce the silverlight xap file size and selected "Reduce XAP size by using applicaiton library caching" to true in Silverlight project properties, which reduced the size of xap file by caching the assemblies.<br />
<br />
When i ran the application, i've encountered "Message: Failed to download a platform extension: System.ComponentModel.DataAnnotations.zip" error and was checking out the cause for this error. At last found that this error is occurring after setting the "Reduce xap file size" to true.<br />
<br />
<b>Solution:</b> <b>Changed the startup project from Silverlight project to Website project in silverlight project properties.</b><br />
<br />
For more information on Silverlight 3 Cached Assemblies check this <a href="http://timheuer.com/blog/archive/2009/07/13/silverlight-3-cached-assembly-feature.aspx">link</a>Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com0tag:blogger.com,1999:blog-4491255236311047122.post-8256894903837655662010-06-18T21:57:00.000-07:002010-09-14T10:54:33.566-07:00How To Create and Consume REST Web Service using WCFRecently i was asked to create a REST web service using WCF. So i have asked my best friend google about this.. but didn't get any working solution for that. After a long research i got REST webservice working. So now i would like to share the things which i have learnt while creating a REST webservice<br />
<h3>First thing is to add WCF Project to your Solution</h3>Just right click on the solution and select " ADD -> New Project -> WCF Service Application "<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfdGTmrGnCTH7guOovEwmiFDyAGfBsT8gNWzuPuGA0pDrqWdcjS7mGlz8C42gPLe3e7w82aO3DZE9n8uvVITw-uNDQOQH7OEyK0uz9cAxxStf56yzAIvOGUwSW5gRXAdpnbUmLjc-YScGD/s1600-h/AddWCFService.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5303657416233123106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfdGTmrGnCTH7guOovEwmiFDyAGfBsT8gNWzuPuGA0pDrqWdcjS7mGlz8C42gPLe3e7w82aO3DZE9n8uvVITw-uNDQOQH7OEyK0uz9cAxxStf56yzAIvOGUwSW5gRXAdpnbUmLjc-YScGD/s320/AddWCFService.png" style="cursor: hand; cursor: pointer; display: block; height: 312px; margin: 0px auto 10px; text-align: left; width: 480px;" /></a><br />
<h3>Changes to be done in Web.Config File</h3><p>By default you will find the end-point binding as "wsHttpBinding", for REST Web service we need to use the end-point as "webHttpBinding".<br />
<br />
Steps for making the above changes<br />
Find System.ServiceModel -> behaviours and add the following end-point behaviour<br />
</p><pre name="code" class="xml"><endpointbehaviors>
<behavior name="WebBehavior">
<webhttp>
</webhttp></behavior>
</endpointbehaviors>
</pre>Find the following code in system.servicemodel -> services<br />
<pre name="code" class="csharp"><endpoint address="" binding="wsHttpBinding" contract="ServiceName.IService1">
....
</endpoint>
</pre>change it to<br />
<pre name="code" class="csharp"><endpoint address="" binding="webHttpBinding" behaviorconfiguration="WebBehavior" contract="ServiceName.IService1">
....
</endpoint>
</pre><br />
At this point of time. Build your solution once and verify everything is working properly. To verify, right click on .svc file(By default it will be Service1.svc) and view it in browser. If the service runs with out throwing any error then you are through the first phase of creating the REST Web service.<br />
<h3>Now we will get into coding part</h3><br />
In your WCF Service, find the Interface Iservice.cs, In the Interface Iservice.cs you can define the methods and Uri template for each method,<br />
<br />
UriTemplate defines the format of the Url with which we can access that perticular method in the service. We use WebGet method to get the url and match with the UriTemplates in the service. (Note: you need to add reference of System.ServiceModel.Web.dll for WebGet Method)<br />
<br />
for example: If you want a method to give your full name by sending FirstName and LastName as parameters, then you can define the UriTemplate as "UriTemplate={firstname}/{lastname}"<br />
where the values in the paranthasis are the parameters for that particular service.<br />
Below you can find the method (CallRestService(string firstname, string lastname)) and its Uri Template.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXhc09qrjuuVZvVLCCZWKPoXkc6bOHZtYmdK7CCQCBG14QBQo81NsbhQ7qNb6rixcgGygqC0n8JkXAMyWVtsjX7GaNc1x7axtUXBJACMDVe4DgdYSQdgB55hyphenhyphenuJJpTAIzRS1GhxYPoEzvE/s1600-h/restExFullName.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5303696412450355266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXhc09qrjuuVZvVLCCZWKPoXkc6bOHZtYmdK7CCQCBG14QBQo81NsbhQ7qNb6rixcgGygqC0n8JkXAMyWVtsjX7GaNc1x7axtUXBJACMDVe4DgdYSQdgB55hyphenhyphenuJJpTAIzRS1GhxYPoEzvE/s400/restExFullName.bmp" style="cursor: hand; cursor: pointer; height: 156px; margin: 0 10px 10px 0; width: 400px;" /></a><br />
Now you are 1 step away from creating a REST web service, you need to define the method(CallRestService(string firstname, string lastname) in Service1.svc.cs file.<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBhT24uxDGVov9MqXAK0loL9-allZ4zpOwXXXTN-YaiADHvFIoMuprjl-95bnw6jwvWIMkuzfwC0fo3wczr2sUQ9TvhtRX4aSW5wwtxVpvdkJkwIkZP2zC9908lkXPPjueXgXeIye-JoFe/s1600-h/method.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5303699147895499922" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBhT24uxDGVov9MqXAK0loL9-allZ4zpOwXXXTN-YaiADHvFIoMuprjl-95bnw6jwvWIMkuzfwC0fo3wczr2sUQ9TvhtRX4aSW5wwtxVpvdkJkwIkZP2zC9908lkXPPjueXgXeIye-JoFe/s400/method.bmp" style="cursor: hand; cursor: pointer; height: 253px; margin: 0 10px 10px 0; width: 400px;" /></a><br />
<br />
rebuild your solution and thats you have created a REST web service which takes two input parameters and returns a string by concatenating two strings.<br />
try to run your webservice and append two parameters first name and last name then hit enter you will see your full name as response from the webservice<br />
<br />
In my case my service is running on localhost port 1908,<br />
http://localhost:1908/Service1.svc<br />
<br />
I need to enter parameters in the url to hit that perticular method<br />
http://localhost:1908/Service1.svc/Kranthi/Kiran<br />
<br />
yeah.. i got the response from the webservice<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc3MikgJSxBgC0k0gG_3bep_XSdkxq40fqoM4EECRpA1BUBByCRKHTwjhj_Dw_6wmeiPYoL1nx_8GLWFOTEMoQChW3YDgvFG2j8nurSveyF1ocz4W3wHsRl6AJKGViYb3AtsfLwR-eBLN3/s1600-h/response.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5303701486751850818" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc3MikgJSxBgC0k0gG_3bep_XSdkxq40fqoM4EECRpA1BUBByCRKHTwjhj_Dw_6wmeiPYoL1nx_8GLWFOTEMoQChW3YDgvFG2j8nurSveyF1ocz4W3wHsRl6AJKGViYb3AtsfLwR-eBLN3/s320/response.bmp" style="cursor: hand; cursor: pointer; height: 60px; width: 320px;" /></a><br />
<br />
Now we need to call this Webservice from the WebApplication, This will be an easy task for us. As we need to create a proxy for WebClient to call the service and just hit the URL http://localhost:1908/Service1.svc/Kranthi/Kiran and get response<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhIejfMrDhiPLPqsliUy2_d0gQJaaGmscABu_Ev3sbHjy07KGa4qFaR50vEn7JGkXRHXhiljCY4TK-JPbjzd-PXJKmT_r6LP3SIP2uAtglt-sB4PSJWqcffoA9frAGqXWnjMh50mhORVB9/s1600-h/PageCS.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5310023881239156738" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhIejfMrDhiPLPqsliUy2_d0gQJaaGmscABu_Ev3sbHjy07KGa4qFaR50vEn7JGkXRHXhiljCY4TK-JPbjzd-PXJKmT_r6LP3SIP2uAtglt-sB4PSJWqcffoA9frAGqXWnjMh50mhORVB9/s320/PageCS.png" style="cursor: hand; cursor: pointer; height: 128px; width: 320px;" /></a><br />
<br />
So here on the page loaded event i am calling the webservice using Webclient DownloadStringCompletedAsync function which takes the uri to be hit and UriKind.<br />
In our case we are using Absolute Uri. <br />
On DownloadString completed eventhandler we will be getting our result in the EventArgs. So e.Result contains the response from the service.<br />
<br />
<b>So the basic steps to create and consume the webservice are:</b><br />
1) Add WCF project to your solution<br />
2) Modify the Web.Config file in the service, changing the endpoint behaviors<br />
3) define the UriTemplate in the interface and define the service method in Service.svc.cs file<br />
4)Create a proxy in the web application.<br />
5) Send the request and get the response<br />
<br />
Thats it for now.. i will be updating the blog with how to consume the created REST webservice soon.... :)Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com0tag:blogger.com,1999:blog-4491255236311047122.post-6693324088315694302010-05-19T10:29:00.000-07:002010-09-14T10:55:32.949-07:00ScrollViewer Scroll Change Event in SilverlightToday i was working with scrollviewer and surprisingly i did not found a scroll changed event... really got irritated and tried to find a workaround for that and would love to share with you all.<br />
I found two workarounds and the good thing is both of them work :) and are mentioned below.<br />
<br />
<b>1st: Catch the scrollbar controls inside the scrollviewer control template and use the scroll event of scrollbar control.</b><br />
<br />
<b>2nd: Create a dependency property which listens the change of Offset properties of ScrollViewer</b><br />
<br />
Here is the <a href="http://docs.google.com/leaf?id=0B69Fb-jzbgZTODUzMDY4MGMtOGFmYy00ZTQ2LWE5ZDItMDdlMTM3MmNmMTYx&hl=en" target="_blank">sample project </a>created and would be straight forward and is self-explanatory.Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com2tag:blogger.com,1999:blog-4491255236311047122.post-16311781764862616752010-05-19T03:01:00.000-07:002010-09-14T10:54:33.567-07:00Unable to Start Debugging. The Silverlight managed debugging package isn't installedRecently i got this error while debugging the silverlight application. When i have googled a bit, i found most of the answers as latest developer runtime is not installed. but this was not my problem.<br />
<br />
<span style="font-weight: bold;">Problem Cause:</span><br />
i have uninstalled the silverlight browser plugin and reinstalled it. So this was causing the problem<br />
<br />
<br style="font-weight: bold;" /><span style="font-weight: bold;">Solution:</span><br />
i have <span style="font-weight: bold;">re-installed the silverlight_tools.exe</span>. this has solved the problemKranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com2tag:blogger.com,1999:blog-4491255236311047122.post-58325095218459225212010-05-16T04:30:00.000-07:002010-09-09T22:46:06.115-07:00Creating a smooth sliding horizontal menu using JQueryFor this example we need the latest version of Jquery which is available at <a href="http://jquery.com/">http://Jquery.com</a><br />
here goes our HTML Code:<br />
<pre class="Cpp" name="code"><div id="”homeSlider”"><ul><li> <br />
<a href=""><img alt="”Out" height="”120″" src="http://www.blogger.com/tab2_outsource_icon.png" width="”120″" /><b>Hello this is Outsourcing</b></a> <br />
</li>
<li> <br />
<a href=""><img alt="”Staff”" height="”120″" src="http://www.blogger.com/tab2_staff_icon.png" width="”120″" /><b>Hello this is staff</b></a> <br />
</li>
<li class="”current”"><br />
<a href=""><img alt="”Support”" height="”120″" src="http://www.blogger.com/tab2_support_icon.png" width="”120″" /> <b>Hello this is support</b></a> <br />
</li>
</ul></div></pre>and the CSS:<br />
<pre class="Cpp" name="code">#slider{
height:122px;
clear:both;
margin:30px 10px 10px;
background:#E6F1FE;}
#slider ul{
list-style-type:none;
height:122px;
overflow:hidden;}
#slider ul li{
display:inline;
float:left;
width:122px;}
#slider ul li a:hover{
cursor:pointer;}
#homeSlider ul li img{
display:block;
float:left;
border:solid 1px #2B78B0;}
#slider .current{
width:500px;}
</pre>Now here comes the magic(JQuery!!)<br />
You are just 5 lines away from creating a smooth sliding Horizontal menu.<br />
<pre class="Cpp" name="code">$(document).ready(function(){
var minWidth = 122;
var maxWidth = 500;
$(”#slider ul li”).hover(function(){
$(”#slider ul li”).animate(
{width:minWidth+”px”},{queue:false,duration:”slow” }
);
$(this).animate(
{width:maxWidth+”px”},{queue:false,duration:”slow” }
);
});
</pre><br />
Now lets understand the JQuery code<br />
1) $(“#slider ul li”).hover(function(){<br />
-> this line binds hover event to all the LI elements after the DOM is loaded<br />
2) $(“#slider ul li”).animate({width: minWidth +“px”}, { queue:false, duration:“slow” });<br />
-> In above line we are animating the width of all the LI elements to minWidth with slow transition and making the queue false as we have to make width of the hovered LI element to maxWidth.<br />
3) $(this).animate({width: maxWidth +“px”}, { queue:false, duration:”slow” });<br />
-> In above line $(this) refers to the hovered element, we are animating the width of the hovered element to max width a slow transition as to create a smooth effect.<br />
<br />
Thats it, with this you should be able to create a smooth horizontal menu with JQuery.. <br />
<br />
Bye for now… be updated to my blog as there are many more to come :)Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com0tag:blogger.com,1999:blog-4491255236311047122.post-82600336885148064422010-05-15T02:10:00.000-07:002010-09-09T22:46:50.637-07:00"Hello World" Blogger Post :)Hello all, <div>By reading the title of this post you may think what non-sense is this, just to say a simple hello to this world does the author need a blog and a blog post.</div><div>But some of you(like me) may be hearing this word very frequently and love to hear that when new technologies or new versions of existing technologies emerge.</div><div><br />
</div><div>Now some of you may get an idea of what will this blog be all about. Yes this is yet another blog by Microsoft .Net developer to share his ideas, learnings and solutions on almost all of the microsoft technologies.</div><div><br />
</div><div>And coming back to "Hello World", If you are not a developer/IT guy then you need the definition of this word "Hello World". This word is used in almost all of the sample projects demonstrated by the authors of new technologies and these projects would be really helpful to the developers who are learning those technologies.</div><div><br />
</div><div>Now it's time to introduce myself to this world and say hello:).</div><div>This is <b>Kranthi Kiran from Hyderabad, India</b> working in software field from the past two and half years. My passion is to code and really love to fix bugs which are high priority and need a quick fix. In this blog i'll post whatever i think is interesting and worth sharing in my day-to-day development. The technologies which i work on are HTML, CSS, Javascript, JQuery, CMS Technologies, Silverlight, WPF, WCF, LINQ, SQL, SSRS and other related technologies.</div><div><br />
</div><div>Let's hope everything goes fine and love to see you back to view my blog....</div><div>Track my blog for updates... Will be back with my stuff loaded in the further postings.. </div><div>Bye for now...</div>Kranthi Kiran Gullapallihttp://www.blogger.com/profile/13159396136601097083noreply@blogger.com0