因胸联盟 发表于 2015-1-16 22:45:49

ASP.NET网页编程之在asp.net 页面中到场skype功能

我见过java运行在手机上,包括很廉价的山寨手机,但是却暂时没发现.net在手机上有什么作为。wp7可能是个转机,但是按照《Java的跨平台就是一句谎言。那.net的跨平台也当之无愧是一句谎言。asp.net|skype|页面ThissampleshowshowtouseSkypefeaturesinyourASP.NET2.0website.BasedupontheSkypeusernameandstandardphonenumber,youtypeintheappropriatefields.SixLinkButtonsarepopulatedwiththestringsthatSkypeneedsinawebsitetodothebasicactions,whichare:
MakeaSkypecallviaSkype.
Requestcontactinformation.
Startachat.
SendafileviaSkype.
Addacontact.
MakeaSkypeOutCall.
Creatingthissample
Istartedthissamplebycreatinganewemptywebsite,selectedtheAddNewItemUnderWebsiteoption,andselectedanewWebUserControltoaddtomyapplicationthatIcalledSkypeSample(itgetsthe.ascxextensionaftercreation).OnthisWebsUserControl,Icreatedthefollowingcontrols:
ALabelwiththeTextpropertySkypeName
ALabelwiththeTextpropertyPhoneNr
ATextBoxwiththeIDtxtSkypeName
ATextBoxwiththeIDtxtPhoneNr
AButtoncalledButton1bydefault,withtheTextpropertysettoPopulate
SixLinkButtonscalled,bydefault,Linkbutton1...
SixstandardtypeImagescalled,bydefault,Image1...
Further,IhaveaddedafolderImagestotheproject,anddownloadedasetofimagesdeveloperscanusefromtheSkypewebsite(Clickheretodownloadtheimages),andchosenthebuttonsIneeded,andaddedthemtothecreatedimagemap.IsetthepathofmycontrolsImage1toImage6totheappropriateimageinmyImagesfolder.
ForButton1,IcreatedaneventcalledPopulate_Click,andthefollowingcodethatwillfirethemethodSetSkypeStatusthatIcreatedlateron.
//GetSpypeStatus
try
{
this.SetSkype();
}
catch
{
//
}
finally
{
//
}
ThenIclickedontheUserControltogotothecode-behind,andcreatedamethodcalledSetSkypeandtheneededstringsfortheapplication.
protectedvoidSetSkype()
{
//SettheImagesonthewebsitetounvisible
Image1.Visible=true;
Image2.Visible=true;
Image3.Visible=true;
Image4.Visible=true;
Image5.Visible=true;
Image6.Visible=true;
//CreatetheStringsthatwillhold
//theneededvaluesandactions
stringSkypeName=txtSkypeName.Text;
stringLandPhone=txtPhoneNr.Text;
stringPathSkypeStatusString="";
stringSkypeAddContactString="";
stringSkypeCallString="";
stringSkypeLandCall="";
stringSkypeChattString="";
stringSkypeProfileString="";
stringSkypeSendFileString="";
Topopulatethestringswithvalues,Icreatedtryblocks.ThefirstblockgetsthestatusoftheSkypeusernamethatistypedinafterthemethodisfired.Asyoucanseeinthecodebelow,Icreatedthreestrings(s1,s2,sT);thelastoneofthethreeinthefirsttryblockstandsforthestringtotalsinceItriedtocreateastringIcanusetogetthestatusoftheSkypecontact.Asyoucanseebelow,thefirstpartofthestringisaURLthatsayswheretolook,andwhaticontouse.Youcouldchangetheword"mediumicon"to,forexample,"largeicon",andalargeiconwillbeshown.ThestringsT=partinthisblocksetstheactualvalueofthestringsTtothestringIwant,thepathtolookplustheSkypeusernameIwantthestatusof.ThevaluesTholdsisthenpassedtotheabovecreatedPathSkypeStatusString;andIassignPathSkypeStatusStringasthevalueoftheImage1URL,soatruntime,thisimageshouldshowamediumiconwiththecurrentstatusoftheuser.
//GetSpypeStatus
try
{
strings1="http://mystatus.skype.com/mediumicon/";
strings2=SkypeName;
stringsT=s1+s2;
PathSkypeStatusString=sT;
Image1.ImageUrl=PathSkypeStatusString;
}
catch
{
//
}
finally
{
//
}
Inthenextpart,IneedmorestringsbecausetheSkypeusernamewillbeinthemiddleofthestring,socreatingthecompletestringisalittlemorecomplicated.s4isimportantinthispartbecausethatistheactionthatwillbeperformedatruntime,ands6inthetextthatwillbevisibleintheLinkButton.Again,IcreatethestringsT,passthevaluetoSkypeCallString,andsetthevalueofLinkButton1tothecontentofSkypeCallString,soatruntime,thisLinkbuttonwillinitiatethecallwhenclicked.Inthecode,theHREFvalueisseenwithnoclosingtagbecausethatoneislateraddedwhenIsetthevalueofthestrings6.
//SetCallString
try
{
//strings1="seecode";
strings2="skype:";
strings3=SkypeName;
strings4="?call";
strings5=".ToString();
strings6=">SkypeMe";
stringsT=s1+s2+s3+s4+s5+s6;
SkypeCallString=sT;
LinkButton1.Text=SkypeCallString;
}
catch
{
//Todo
}
finally
{
//Todo
}
Irepeatthisforalltheactionsthatcanbeperformedbytheuser,settingthevaluesoftheLinkButtonstotheactionsIwantthemtoperform.Itsclearwhythedifferentactionsalwayslooklike?call,?chatetc.
Runningthesamplecode
Torunthesamplecode,youjustopentheSkypeSamplefolderwithVisualStudio,underthemenuoptionFile,Open,andtheselectthewebsite.Thecodeshouldbeloaded,andwhenyouhitF5,thesampleapplicationshouldrun.
Furtheruse
ThissampleiseasytousedynamicallywhenyoustoretheSkypeusernameandphonenumberinadatabaseandpresentthesevaluesinyourwebsite,with,forexample,aDetailControlthatyouloadwithadatasource.WhenyousettheSkypeusernameandphonenumberasDataKeysfortheDetailControl,youcanusethevaluestheyholdatruntimeforpopulatingthestrings(Skypeusernameandphonenumber).BelowisasamplethatshowshowyoucouldsetthepropertiesfromSkype.
//SetSkypeNameandSkypeLandCallstringvaluesdynamically
try
{
//SetStringSkypeName
stringSkypeName=DetailsView1.DataKey["Skype"].ToString();
//SetstringSkypeLandCall
stringSkypeLandCall=DetailsView1.DataKey["CompanyPhone"].ToString();
}
catch
{
//Todo
}
finally
{
//Todo
}
PointsofInterest
Iamnotsayingthatthecodeisperfectbutitworkswellfrommylaptop.WhenIrequestthewebsitefrommylocalserver,allSkypeoptionswork.ThenameSkypeiscopyrightofSkypeLimited.
呵呵,那你就关注微软的招聘信息以及别人的招聘经验啊,还有也不一定去做技术的,你如果真的想去就多了解了解。(其实我的意思是说想到微软做技术是很不容易的。

柔情似水 发表于 2015-1-19 16:28:42

当然我们在选择Asp.net主机是,除了要考虑服务提供商在版本是否是实时更新以外,机房的环境和配置也是非常重要的,通常选择骨干网的机房,在速度和稳定性上会非常有保证。

仓酷云 发表于 2015-1-24 14:30:17

主流网站开发语言之CGI:CGI就是公共网关接口(CommonGatewayInterface)的缩写。它是最早被用来建立动态网站的后台技术。这种技术可以使用各种语言来编写后台程序,例如C,C++,Java,Pascal等。

海妖 发表于 2015-2-1 16:51:36

当然我们在选择Asp.net主机是,除了要考虑服务提供商在版本是否是实时更新以外,机房的环境和配置也是非常重要的,通常选择骨干网的机房,在速度和稳定性上会非常有保证。

活着的死人 发表于 2015-2-7 10:04:25

Asp.net:首先来说,Asp.net和Asp没什么关系,看着像是升级版本什么的,其实没什么联系。Asp是脚本编程,用的是ASP语言,而ASP.net用的是C#语言,完全不同的东西。

愤怒的大鸟 发表于 2015-2-21 16:49:47

它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。

莫相离 发表于 2015-3-6 20:28:41

弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。

灵魂腐蚀 发表于 2015-3-13 08:09:54

HTML:当然这是网页最基本的语言,每一个服务器语言都需要它的支持,要学习,这个肯定是开始,不说了.

第二个灵魂 发表于 2015-3-20 17:22:23

PHP的源代码完全公开,在OpenSource意识抬头的今天,它更是这方面的中流砥柱。不断地有新的函数库加入,以及不停地更新,使得PHP无论在UNIX或是Win32的平台上都可以有更多新的功能。它提供丰富的函数,使得在程式设计方面有着更好的资源。目前PHP的最新版本为4.1.1,它可以在Win32以及UNIX/Linux等几乎所有的平台上良好工作。PHP在4.0版后使用了全新的Zend引擎,其在最佳化之后的效率,比较传统CGI或者ASP等技术有了更好的表现。
页: [1]
查看完整版本: ASP.NET网页编程之在asp.net 页面中到场skype功效