Friday, May 22, 2009

Element Binding in Silverlight 3

Hi Friends,

In silverlight 3,  we can have direct element binding. the below example will demonstrate the same in simple xaml codes.  So What ever you type in txt1 will automatically get binded to txt2. 

Xaml Code :

<TextBox  x:Name="txt1" Text="welcome"/>

<Textbox  x:Name="txt2" Text={Binding Text, ElementName=txt1}/>

Cheers!
Muthaiah
www.fmass.com

Simple Navigation link to a different website in silverlight 2.0

Hi Friends,

This following code explains how to make a simple navigation link , which opens in a seperate browser page in silverlight 2.0

Xaml Code:

<TextBlock HorizontalAlignment="Right" Margin="0,32,0,22" Width="118" Text="Fmass - creativity powered" TextWrapping="Wrap" Foreground="#FF808080" TextDecorations="Underline" x:Name="fmasstxt" MouseLeftButtonDown="fmass_MouseLeftButtonDown" Cursor="Hand"/>

C# code:

using System.Windows.Browser;

private void fmass_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            HtmlPage.Window.Navigate(new Uri("http://www.fmass.com") , self);

        }



Cheers! 
Muthaiah
www.fmass.com

Thursday, May 21, 2009

Continous background music player in silverlight 2.0

Hi Friends,

This is a small example of how to incorporate background music for a website in silverlight 2.0, which will have continous stream of music, where you shuld make sure the editing of music is in such a  way that, you can feel as if it is continous.

Xaml code :

<MediaElement Height="34" Source="assets/bgmusic.mp3" MediaEnded="bgaudioplayer_MediaEnded"   Position="0" HorizontalAlignment="Right" Margin="0,0,44,227" VerticalAlignment="Bottom" Width="32" x:Name="bgaudioplayer"/>

C# backend code :

private void bgaudioplayer_MediaEnded(object sender, RoutedEventArgs e)
        {
            bgaudioplayer.Position = System.TimeSpan.FromSeconds(0);
            bgaudioplayer.Play();
        }


Cheers!
Muthaiah
www.fmass.com

Sunday, November 2, 2008

Silverlight 2.0.31005.0 - new release - steps to follow for installation

Hi Friends,

Steps to follow for installing new version of Silvelright 2.0.31005.0:

Step 1 : Uninstall Microsoft Silverlight, Microsoft Silverlight Tools for VS2008, Microsoft Silvelright SDK

Step 2 : Uninstall expression blend 2.5 June Preview



Step 5 : Install Expression Blend 2 Trial version valid for 60 days, then you need a product key.

Step 6 : Install Expression Blend SP1

Now you are set to work with latest release of Silvelright. Good thing with the latest release is even you can setup for Visual Studio 2008 Web Express Edition by installing SP1 for the same.

Actually little bit of changes are done and new controls like preloaders, certain skins are changed , but so far the target was to close june preview version and add all to SP1 of VS and Blend. In turn to concentrate on sales of the product by Microsoft!

Anyways! I feel the workarea of Blend is much more faster comparitively.


Thanks!

Regards,
Muthaiah.


New Silverlight version 2.0.31005.0 tips

Hi Friends, 

There are few changes with new release of Silverlight 2.0.31005.0! Especially in the visual state Manager June Preview coding style 



   
Same animation in the latest release has change of style in coding and few more options are added to VSM almost what a designer can do with Expression blend for WPF. Codeless animations can be made by a designer using States in Blend. 
Here is the same animation in new release :



Don't think, too much of difference, pretty simple - in the transitions , previously we had Duration , now it is replaced with GeneratedDuration. :)


Thanks!
Regards, 
Muthaiah.

Friday, May 16, 2008

Silverligh2.0 - Tip 2

Hi Friends,


Back to back tips from my end.

I hope you all are able to understand the basics of Silverlight2.0. Soon going to publish lot of video tutorials in my personal site http://www.fmass.in/. May be within another two weeks. Especially about Silverlight,LINQ,WCF and SQL Integeration.

When you bind data to a controls property you need to declare that property="{binding }"

Example :

&ltTextBlock Text="{binding Textvaluefromdb}">


Cheers -:)
Muthaiah Thiagarajan.

Silverlight2.0 - Tip 1



Hi Friends,

When you create a web application as i discussed in the previous post. Then you can open the page.xaml page in .net itself and now you have also design interface of xaml codes in silverlight 2.0.

So now you get very good intellisense in .net for xaml codes, thanks to Microsoft. Still the design panel needs to update and should have complete look and feel of the page. I hope they bring soon as a beta tool for VS2008. Anyways as per experts speech in MIX '08. It has been tld that this design interface will get good shape before the release of Visual Studio 2010.

Now coming the tip :

In silverlight 2.0 , since you have a intellisense for all controls, like CSS for html. Silverlight2.0 provides App.xaml page.

So you can set the style in App.xaml and just like you css through id or class on html page, here you can call that style in the Page.xaml for that particular control.

You need to put all styles under





Now you can call this in the Page.xaml for all Hyperlinkimage control by adding a property to the control i.e) Style="HyperlinkImage"


Cheers -:)
Muthaiah Thaigarajan

Silverlight2.0 - Concept 1

Hi Friends,

I am coming up with new uploads in my personal site soon. Expect Soon -:)

Now a fact about Silverlight2.0 Technology:

In new Silverlight 2.0 , after installing Silverlight Beta tools for Visual Studio 2008 Professional.

When u open a new project with Silverlight and backend as C#/VB.It asks whether u want to have a website or web application. Web application is preferrable. Here it creates one silverlight project and one asp web application project under one Solution. We get two pages one Page.xaml and another App.xaml under silverlight web application and also you get a seperate project under the same solution for aspx pages.

Here in this Microsoft has brought a excellent concept of making a .xap file when you built the entire application/website , this file falls in the clientbin folder of aspx project. So this xap file will serve the cause of Silverlight project inside the aspx project.

Here inside the aspx project other than default.aspx, we get another two test pages one in aspx format and another in html format. You can built the entire solution and view the silverlight on browser through either of the test pages. But if you any data binding , you can one view those in aspx test page.

To learn more click here.

Cheers -:)
Muthaiah Thiagarjan.

Monday, March 3, 2008

ASP.Net Sending E-mail Attachment

Sending E-mail Attachment

Let us now look at how to include attachments to our e-mail. Open the web-page in design mode and add an HTML file upload control to the form. Set it to run at Server, and switch to code-behind to make changes in our previous method.

Dim msg As New Net.Mail.MailMessage(
_txtFrom.Text,
_txtTo.Text,
_txtSubject.Text,
_txtMessage.Text)
If fileUpload.PostedFile.FileName = "" Then
Else
msg.Attachments.Add( _
New System.Net.Mail.Attachment _
(fileUpload.PostedFile.FileName))
End If

All you need to do is check if the user posted a file or not, and if he did, then you need to create a new Net.Mail.Attachment object and add that to the MailMessage Object's Attachments collection. The line of code doing that could be broken down into the following, for simplicity;

Dim strName As String = fileUpload.PostedFile.FileName
Dim myAttachment As System.Net.Mail.Attachment
myAttachment = New Net.Mail.Attachment(strName)
msg.Attachments.Add(myAttachment)

ASP.Net - Send simple e-mail

Send simple e-mail

The code to send a simple e-mail is pretty simple and very small. There isn't much to explain either.

Dim msg As New Net.Mail.MailMessage(
_txtFrom.Text, _txtTo.Text,
_txtSubject.Text, _txtMessage.Text)

Dim mySmtp As New Net.Mail.SmtpClient("localhost")
Try
mySmtp.Send(msg)
lblResult.Text = "Mail Sent"
Catch ex As Exception
lblResult.Text = ex.Message
End Try