CodeBehind vs CodeFile

Posted: June 12, 2014 in ASP.Net

CodeBehind
Needs to be compiled and the compiled binary is placed in the bin folder of the website.

<%@ Page Title="" Language="C#" MasterPageFile="~/YourMasterPage.Master" AutoEventWireup="true" CodeBehind="YourFile.aspx.cs" Inherits="YourPage" %>

CodeFile
You provide the source file with the solution for deployment and .NET compiles the code when needed.

<%@ Page Title="" Language="C#" MasterPageFile="~/YourMasterPage.Master" AutoEventWireup="true" CodeFile="YourFile.aspx.cs" Inherits="YourPage" %>
Advertisements

To play , you can try the following:

sing Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework;
using System.IO;

Stream stream = TitleContainer.OpenStream("MySoundFile.wav");
SoundEffect effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();

To make a windows phone device vibrate, you can try the following:

using Microsoft.Devices;

VibrateController vibrate = VibrateController.Default;
vibrate.Start(TimeSpan.FromMilliseconds(1000));

Convert String to TimeSpan

Posted: March 15, 2012 in ASP.Net

To convert a String to TimeSpan, you can try the following:

TimeSpan myTimeSpan = TimeSpan.Parse("00:00:30");

To get a t of all songs from your Media Library and bind it to a ListBox control, first add the control in your XAML file as follows:

<ListBox x:Name="myListBox" />
using Microsoft.Xna.Framework.Media;

private void ListSongs()
{
  MediaLibrary myLib = new MediaLibrary();
  var mySongName = (from m in myLib.Songs select m.Name).ToList();
  myListBox.ItemsSource = mySongName;
}

Disable Lock Screen

Posted: March 14, 2012 in Windows Phone 7 & Mango

If you need to disable the lock screen while your app is running, you can try the following:

using Microsoft.Phone.Shell;

PhoneApplicationService phoneAppService = PhoneApplicationService.Current;
phoneAppService.UserIdleDetectionMode = IdleDetectionMode.Disabled;</code>

It is a good idea to add a Review My App button to your windows phone applications To do this, you can simply add the following to any button click event handler:

using Microsoft.Phone.Shell;
if (PhoneApplicationService.Current.State.ContainsKey("KeyName"))
{
  // Do something
}