我想让responsetext返回的dropdownlist控件放在Default7页面的id=time的div中,新手请高人解答,谢谢!<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<body><script type="text/javascript">function ajaxFunction()
 {
 var xmlHttp;
 
 try
    {
   // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
 catch (e)
    {  // Internet Explorer
   try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
   catch (e)
      {      try
         {
         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         }
      catch (e)
         {
         alert("您的浏览器不支持AJAX!");
         return false;
         }
      }
    }

    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
//        document.write(xmlHttp.responseText);
       document.getElementById("time").innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET","time.aspx",true);
    xmlHttp.send(null);

 }
</script><form name="myForm">
用户: <input type="text" name="username" onkeyup="ajaxFunction();" />
<%--时间: <input type="text" name="time" />--%>
<p>
<div id="time">dsvgdsbfv</div>
</p></form>
</body>
</html>time页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="time.aspx.cs" Inherits="time" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>    <form id="form1" runat="server">
    <div id="div1">
   
      <asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>
   
    </div>
    </form>
</body>
</html>

解决方案 »

  1.   

    我想让responsetext返回的dropdownlist控件放在Default7页面的id=time的div中-----------------------有这么搞的吗?  你可以用ajax返回 json数据,然后直接添加到 dropdownlist 中。
    风行下载安装
    皮皮播放器下载
    uusee网络电视
      

  2.   

    ajax的话,最好返回数据,通过js动态生成html
      

  3.   

    [Quote=引用 1 楼 gongsun 的回复:]
    我想让responsetext返回的dropdownlist控件放在Default7页面的id=time的div中-----------------------有这么搞的吗? 你可以用ajax返回 json数据,然后直接添加到 dropdownlist 中。-----------------------
    恩,谢谢了,我去看下JSON怎么用。