Function GetList (){
Document. getElementById ("ListBox1"). options. length = 0;
Var param = getDDLTextandValue ();
Var url = "GetUserList. aspx? SessionName = "+ encodeURI (param ));
Send_request (url );
}
Var XML_Http_Request = false;
Function createXMLHttpRequest (){
XML_Http_Request = false;
If (window. XMLHttpRequest ){
XML_Http_Request = new XMLHttpRequest ();
If (XML_Http_Request.overrideMimeType ){
XML_Http_Request.overrideMimeType ("text/xml ");
}
}
Else if (window. ActiveXObject ){
Try {
XML_Http_Request = new ActiveXObject ("Msxml2.XMLHTTP ");
} Catch (e ){
Try {
XML_Http_Request = new ActiveXObject ("Microsoft. XMLHTTP ");
} Catch (e ){}
}
}
}
Function send_request (url ){
CreateXMLHttpRequest ();
If (! XML_Http_Request ){
Window. alert ("Cannot create XMLHttpRequest instance! ");
Return false;
}
XML_Http_Request.onreadystatechange = process_Request;
XML_Http_Request.open ("GET", url, true );
XML_Http_Request.send (null );
}
Function process_Request (){
If (XML_Http_Request.readyState = 4 ){
If (XML_Http_Request.status = 200 ){
Var xmlDoc = XML_Http_Request.responseText;
// Var xx = xmlDoc. split (',');
// For (var I = 0; I ++; I <xx. length)
//{
// If (xx [I]! = "")
//{
// Var yy = xx [I]. split ('| ');
// LISTAddNew (yy [0], yy [1], DropDownList1 );
//}
//}
Var str2 = new Array ();
Str2 = xmlDoc. split (",");
Var list1 = document. getElementById ("ListBox1 ");
For (I = 0; I <str2.length; I ++)
{
If (str2 [I]! = "")
{
Var yy = new Array ();
Yy = str2 [I]. split ("| ");
Var newOption11 = new Option (yy [0], yy [1]);
List1.options. add (newOption11 );
}
}
}
Call GetList
}
}
Code of the background value page (GetUserList:
String Groupid = string. Empty;
Protected void Page_Load (object sender, EventArgs e)
{
Groupid = Request. QueryString ["SessionName"];
Try
{
OleDbConnection myconn = new OleDbConnection ();
Myconn. ConnectionString = ConfigurationManager. ConnectionStrings ["strconn"]. ConnectionString;
Myconn. Open ();
OleDbCommand mycomm = new OleDbCommand ();
If (Groupid = "-1 ")
Mycomm. CommandText = "select * from TGroup_User order by userid ";
Else
Mycomm. CommandText = "select * from TGroup_User where Groupid =" + Groupid + "order by userid ";
Mycomm. CommandType = CommandType. Text;
Mycomm. Connection = myconn;
OleDbDataReader mydr = mycomm. ExecuteReader ();
String s = "";
If (mydr. HasRows)
{
While (mydr. Read ())
{
S = s + ',' + mydr ["UserId"]. ToString ();
}
}
If (s. Length! = 0)
{
S = s. Substring (1, s. Length-1 );
}
Else
{
S = "-100 ";
}
// Response. Write (s );
Mydr. Close ();
String SQL = "";
If (Groupid = "-1 ")
SQL = "select * from TUser where IsAdminUser = '1' order by Country DESC, UserName ";
Else if (Groupid = "-2 ")
SQL = "select * from TUser where IsAdminUser = '0' order by Country DESC, UserName ";
Else
SQL = "select * from TUser where UserId in (" + s + ") order by Country DESC, UserName ";
String content = string. Empty;
Mycomm. CommandText = SQL;
Mydr = mycomm. ExecuteReader ();
If (mydr. HasRows)
{
While (mydr. Read ())
{
Content = content + ',' + mydr ["UserName"]. ToString ();
Content = content + '|' + mydr ["UserId"]. ToString ();
}
}
Myconn. Close ();
Mycomm. Dispose ();
Mydr. Close ();
Response. Write (content );
Response. End ();
// DataSet custds = new DataSet ();
// Custds. Load (mydr, LoadOption. OverwriteChanges, new string [] {"TableName "});
// Response. Write (custds. GetXml ());
// Response. End ();
}
Catch (Exception ex)
{
}
Finally
{
}
}