Add Skype functionality to the ASP.net page

Source: Internet
Author: User
Tags closing tag tostring visual studio
asp.net|skype| page

This sample shows you to use Skype features in your ASP.net 2.0 website. Based upon the Skype user name and standard phone number, type in the appropriate fields. Six LinkButtons are populated with the strings of that Skype needs into a website to do the basic actions, which are:

Make a Skype call via Skype.
Request contact information.
Start a chat.
Send a file via Skype.
Add a contact.
Make a Skype out call.
Creating this sample
I started this sample by creating a new empty website, selected the ADD new Item Under website option, and selected a new Webusercontrol to "My application" I called skypesample (it gets the. ascx extension after creation). On this websusercontrol, I created the following controls:

A Label with the Text property Skype Name
A Label with the Text property Phone Nr
A TextBox with the ID txtskypename
A TextBox with the ID txtphonenr
A Button called Button1 by default, with the Text property set to Populate
Six linkbuttons called, by default, Linkbutton1 ...
Six standard type Images called, by default, Image1 ...
Further, I have added a folder Images to the project, and downloaded a set of Images developers can use the Skype Web Site (Click here to download the images), and chosen the buttons I needed, and added to the them image map. I set the path of my controls Image1 to Image6 to the appropriate image on my Images folder.

For Button1, I created a event called Populate_click, and the following code that would fire the method Setskypestatus tha T I created later on.

Get Spype Status
Try
{
This. Setskype ();
}
Catch
{
//
}
Finally
{
//
}
Then I clicked on the "UserControl" to "Go" code-behind, and created a method called Setskype and the needed strings fo R the application.

protected void Setskype ()
{

Set the Images on the website to unvisible
Image1.visible = true;
Image2.visible = true;
Image3.visible = true;
Image4.visible = true;
Image5.visible = true;
Image6.visible = true;

Create the Strings that'll hold
The needed values and actions

string skypename = Txtskypename.text;
string landphone = Txtphonenr.text;
String pathskypestatusstring = "";
String skypeaddcontactstring = "";
String skypecallstring = "";
String skypelandcall = "";
String skypechattstring = "";
String skypeprofilestring = "";
String skypesendfilestring = "";
To populate the strings with values, I created try blocks. The ' the ' of the ' the ' of the ' the ' of the ' the ' of the ' the ' is ' typed ' is fired. As you can the code below, I created three strings (S1, S2, ST); The last one of the ' three in the ' the ' the ' the ' the ' I stands for the ' string total since I tried to create a string I can Get the status of the Skype contacts. As you can the below, the the "the" the "the", "is a" URL that says where to look, and what icon to use. You are could change the word "Mediumicon" to, for example, "LargeIcon", and a large icon would be shown. The string st= part is sets the actual value of the string ST to the string I want and the path to look plus the S Kype User name I want the status of. The value ST holds is then passed to the above created pathskypestatusstring; and I assign pathskypestatusstring as the value of the Image1 URL, so at runtime, this is image should show a medium icon wit H The current status of the user.

Get Spype Status
Try
{
string S1 = "http://mystatus.skype.com/mediumicon/";
string s2 = Skypename;
String ST = s1 + s2;
pathskypestatusstring = ST;
Image1.imageurl = pathskypestatusstring;
}
Catch
{
//
}
Finally
{
//
}
In the next part, I need more strings because the Skype user name would be in the middle of the string, so creating the COM Plete string is a little more complicated. S4 is important into this part because that's the action that'll be performed at runtime, and S6 in the text that would be Visible in the LinkButton. Again, I Create the string ST, pass the value to Skypecallstring, and set the value of LinkButton1 to the content of Skype Callstring, so in runtime, this Linkbutton would initiate the call when clicked. In the code, the HREF value are seen with no closing tag because, which is later added when I set the value of the string S6.

//set callstring
Try
{
   //string S1 = "= =";
    string s2 = "Skype:";
    string s3 = Skypename;
    String s4 = "? Call";
    String s5 = ' ". ToString ();
    String s6 = ">skype Me";
    String ST = S1 + s2 + s3 + S4 + S5 + S6;
    skypecallstring = ST;
    linkbutton1.text = skypecallstring;
}
Catch
{
   //todo
}
finally
{
   //todo
}
I Repeat this is the "the" to "the" and "the" performed by the user, setting the values of the ' linkbuttons to the actions I Want them to perform. It ' s clear why the different actions always look like call,? chat etc.

Running the sample code
To run the sample code, your just open the Skypesample folder with Visual Studio, under the menu option File, open, and the Select the website. The code should be loaded, and then you hit F5, the sample application should run.

Further use
This sample was easy to use dynamically when your store the Skype user name and phone number in a database and present Values in your website, with, for example, a detailcontrol so you-load with a data source. When you set the "Skype" user name and phone number as DataKeys for the Detailcontrol, your can use the values they hold at R Untime for populating the strings (Skype user name and phone number). Below is a sample this shows how to you could set the properties from Skype.

Set Skypename and Skypelandcall string values dynamically
Try
{
Set String Skypename
String skypename = detailsview1.datakey["Skype"]. ToString ();
Set string Skypelandcall
String skypelandcall = detailsview1.datakey["Companyphone"]. ToString ();
}
Catch
{
Todo
}
Finally
{
Todo
}
Points of Interest
I am not saying this code is perfect but it works. When I request the website to the "I local server", all Skype options work. The name Skype is copyright of Skype Limited.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.