1、如果让你做一个类似Windows Live Messenger的系统,从技术架构上你会怎样规划?提示:包括客户端、Web Messenger和服务器端。2、完成一段使用Javascript读取RSS/XML数据的代码。提示:RSS/XML来自网站http://www.example.com/news.rss,需要异步调用。3、一个ASP.NET的应用程序页面中通过GridView/DataGrid列出了10条数据。现在希望增加一列CheckBox列,可以让用户单选或多选所要的记录。并且需要增加一个全选的按钮,按下后能将所有记录前的CheckBox都打勾并且选择全部的记录。请至少给出两种方式完成这一功能需求。提示:可通过Javascript或者ASP.NET实现。
{
var GridView1 = document.getElementById("<%=GridView1.ClientID %>");
for(i = 1;i < GridView1.rows.length; i++)
{
GridView1.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = oCheckbox.checked;
}
}
第2种方式:function CheckAll1(name)
{
var elements = document.getElementsByTagName("input");
for (i=0; i< elements.length; i++)
{
if (elements[i].type == "checkbox")
{
elements[i].checked =name.checked
}
}
}
JS代码:// JScript 文件 var xmlhttp;
function getdata()
{ //创建异步对象
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
//加载服务器-注意URL参数的使用
xmlhttp.Open("GET","http://www.example.com/news.rss",true)
//异步对象事件挂钩
xmlhttp.onreadystatechange=stateChange;
//发送请求-无参数
xmlhttp.Send(null);
}
function stateChange()
{
if(xmlhttp.readystate==4 && xmlhttp.status==200)
{
//获取所有返回的数据,用VBS方法转码
var data=bytes2BSTR(xmlhttp.ResponseBody);
//过滤自己需要的数据 document.getElementById("divdata").innerHTML=data;
//显示结果
document.getElementById("divdata").style.visibility="visible";
}
}VBS代码:' VBScript 文件function bytes2BSTR(vIn)
dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn=""
for i=1 to LenB(vIn)
ThisCharCode=AscB(MidB(vIn,i,1))
if ThisCharCode<&H80 Then
strReturn=strReturn & Chr(ThisCharCode)
else
NextCharCode=AscB(MidB(vIn,i+1,1))
strReturn=strReturn&Chr(CLng(ThisCharCode)*&H100+CInt(NextCharCode))
i=i+1
end if
next
bytes2BSTR=strReturn
end function
【微软专栏】MSN架构分析
你可以看看这个
Challenges
The only other exception to the "commands always end with a newline" rule is a challenge (CHL). Since they are only sent from the client and never from the server, this should not make parsing any more difficult. Challenges will be explained in the session section. changlenge命令是单向的,只从客户端发出。
Errors
When something goes wrong, the server sends an error command. These are just regular commands, but the command name is always a three digit number. The number is followed by the transaction ID of the command it is replying to. An error can be sent from any of the three types of servers. Below is a list of error numbers and what they represent. Error命令只是个数字符号,三位。跟在transactionID之后。
Error Codes
200 Syntax error
201 Invalid parameter
205 Invalid user
206 Domain name missing
207 Already logged in
208 Invalid username
209 Invalid fusername
210 User list full
215 User already there
216 User already on list
217 User not online
218 Already in mode
219 User is in the opposite list
280 Switchboard failed
281 Transfer to switchboard failed
300 Required field missing
302 Not logged in
500 Internal server error
501 Database server error
510 File operation failed
520 Memory allocation failed
600 Server is busy
601 Server is unavaliable
602 Peer nameserver is down
603 Database connection failed
604 Server is going down
707 Could not create connection
711 Write is blocking
712 Session is overloaded
713 Too many active users
714 Too many sessions
715 Not expected
717 Bad friend file
911 Authentication failed
913 Not allowed when offline
920 Not accepting new users
924 * Passport account not yet verified
Transaction IDs
Every command sent from a client to a server must contain a transaction ID. When a server sends a reply to one of these messages, it will contain the same exact transaction ID, so that the client knows which command the server was replying to. A transaction ID is always a number between 0 and 4294967295 (2^32 - 1). It would probably be best for a client to start at 0 and increment the ID every time it sends a command. The transaction ID is always sent right after the three character command name and before the parameters, with spaces in between. According to the official MSN Messenger Service 1.0 Protocol draft, when the server sends a command to a client that is not in response to a client command, it should use a transaction ID of 0. However, the server has never sent any transaction ID in those commands to me, so it's possible the statement in the draft was incorrect. 交易ID,在每个从客户端送到服务器的命令中,都包含有一个交易ID。然后服务器给一个应答命令,也要包含同样的交易ID。 范围 2^32----1。理论上该是从0开始,然后每次命令加一。
Screen Names
All screen names on MSN are URL quoted so that they fit in one word and can be easily parsed. URL quoting is where spaces are replaced with %20 along with other special characters. 空格=%20
MD5
Whenever a password is sent to the server, it is encoded using the MD5 algorhythm. The result is always lowercase and hexidecimal. If you want to check to see if you are encoding correctly, try encoding the hash 1013928519.693957190 added to mypassword, or in other words, 1013928519.693957190mypassword. The result should be 6f3963009fc8a9d2b2ff137da0905c55 msn密码传递是经过加密的,算法为MD5。
这个只是一个方法!和还有。NET C#的方法
ASP.NET方法
用CheckBox事件 protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
CheckBox cbx = (CheckBox)sender;
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox ch = (CheckBox)gvr.FindControl("CB");
ch.Checked = cbx.Checked;
} }