在做一个搜索的功能,可以被其他网站调用,但是怎么样被对方嵌入进去没想明白,
好像iframe,frameset,javascript效果都不是很理想。
帮帮我啦,就还有两周时间了。

解决方案 »

  1.   

    iframe,不过看源代码可以看出来,最好用javascript
      

  2.   

    <script src="picker.js" language="javascript"></script>
    <script language="javascript">
             var Picker=new PickerControl();
    </script>
    </HEAD>
    <body>
    <form><a onclick="Picker.show('test.aspx',null);"><IMG alt="选择合同类别" src="/baseweb/images/ico/finds.gif" border="0"></a>
    </form>
    </body>test.aspx
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid/>
    </form>
    </body>
    picker.js://---
    function PickerControl(){
      var picker=this;
      this.pickerPad=null;
      this.pickerClose=null;
      this.pickerAbout=null;
      this.head=null;
      this.body=null;
      this.targetID;
      this.targetName;
      this.targetValue;
      this.targetCode;
      this.targetModel;
      this.targetPrice;
      this.targetUnit;
      this.source;
      /************** 加入底板及阴影 *********************/
      this.addPickerPad=function(){
       document.write("<div id='divPickerpad' style='position:absolute;top:100;left:0;width:400;height:250;display:none; z-index:1000;filter:progid:DXImageTransform.Microsoft.Shadow(color=#777777, Direction=135, Strength=3) alpha(Opacity=90);'>");
       
       document.write("<iframe id='PickerFrame' scrolling='yes' src='' frameborder=0 height=250 width=350></iframe>");   document.write("</div>");
       picker.pickerPad=document.all.divPickerpad;
       picker.pickerFrm=document.all.PickerFrame;
      }
      /****************** Show Picker *********************/
      this.show=function(defaultURL,targetName,targetID,targetValue,width,height,scrolling,sourceObject,targetCode,targetModel,targetPrice,targetUnit){
       if(picker.pickerPad.style.display=="") { picker.hide();return false;}
       if(targetName==undefined) {
        alert("未设置目标对象. \n方法: Picker.show(string 搜索页面URL,obj 目标名称,obj 目标ID,obj 目标Value,Width,Height,obj 点击对象);\n\n搜索页面URL:数据选择页面.\n目标名称:接受返回的名称.\n目标ID:接受返回的ID.\n目标Value:接受返回的值.\n点击对象:点击这个对象弹出picker,默认为目标对象.\n");
        return false;
       }else{  
       picker.targetName=targetName;
       }
       picker.source=picker.targetName;
    if(defaultURL&&picker.pickerFrm.src!=defaultURL){picker.pickerFrm.src="about:blank";picker.pickerFrm.src=defaultURL;}
    if(targetID)picker.targetID=targetID;
    if(targetValue)picker.targetValue=targetValue;
    if(targetModel)picker.targetModel=targetModel;
    if(targetPrice)picker.targetPrice=targetPrice;
    if(targetUnit)picker.targetUnit=targetUnit;
    if(targetCode)picker.targetCode=targetCode;
    if(width){picker.pickerFrm.width=width;}else{picker.pickerFrm.width=400;}
    if(height){picker.pickerFrm.height=height;}else{picker.pickerFrm.height=250;}
    picker.pickerFrm.scrolling="no";
    picker.pickerPad.style.display="";
       //****************调整位置**************//
       var offsetPos=picker.getAbsolutePos(picker.source);//计算对象的位置;
       var calTop=offsetPos.y  + 2;
       var calLeft=offsetPos.x ;   picker.pickerPad.style.pixelLeft=calLeft;
       picker.pickerPad.style.pixelTop=calTop;
      }
      /****************** 计算对象的位置 *************************/
      this.getAbsolutePos = function(el) {
       var r = { x: el.offsetLeft, y: el.offsetTop };
       if (el.offsetParent) {
        var tmp = picker.getAbsolutePos(el.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
       }
       return r;
      };
     
      /************** 隐藏面板 *********************/
      this.hide=function(){
       picker.pickerPad.style.display="none";
      }
       this.displayShow=function(){
       picker.pickerPad.style.display="";
      }
      /************** 返回数据 *********************/
      this.pick=function(name,id,value,code,model,price,unitt){
       if(name&&picker.targetName)picker.targetName.value=name;
       if(id&&picker.targetID)picker.targetID.value=id;
       if(value&&picker.targetValue)picker.targetValue.value=value;
       if(code&&picker.targetCode)picker.targetCode.value=code;
       if(model&&picker.targetModel)picker.targetModel.value=model;
       if(price&&picker.targetPrice)picker.targetPrice.value=price;
       if(unitt&&picker.targetUnit)picker.targetUnit.value=unitt;
       picker.hide();
      }
      /************** 从这里开始 *********************/
      this.setup=function(defaultDate){
       picker.addPickerPad();
      }
      picker.setup();
     }
      

  3.   

    这里有个写在div里的:
    <script src="picker.js" language="javascript"></script>
    <script language="javascript">
             var Picker=new PickerControl();
    </script>
    </HEAD>
    <body>
    <form><a onclick="Picker.show('test.aspx',null);"><IMG alt="选择合同类别" src="/baseweb/images/ico/finds.gif" border="0"></a>
    </form>
    </body>test.aspx
    <body>
    <form id="Form1" method="post" runat="server">
    <asp:datagrid/>
    </form>
    </body>
    picker.js://---
    function PickerControl(){
      var picker=this;
      this.pickerPad=null;
      this.pickerClose=null;
      this.pickerAbout=null;
      this.head=null;
      this.body=null;
      this.targetID;
      this.targetName;
      this.targetValue;
      this.targetCode;
      this.targetModel;
      this.targetPrice;
      this.targetUnit;
      this.source;
      /************** 加入底板及阴影 *********************/
      this.addPickerPad=function(){
       document.write("<div id='divPickerpad' style='position:absolute;top:100;left:0;width:400;height:250;display:none; z-index:1000;filter:progid:DXImageTransform.Microsoft.Shadow(color=#777777, Direction=135, Strength=3) alpha(Opacity=90);'>");
       
       document.write("<iframe id='PickerFrame' scrolling='yes' src='' frameborder=0 height=250 width=350></iframe>");   document.write("</div>");
       picker.pickerPad=document.all.divPickerpad;
       picker.pickerFrm=document.all.PickerFrame;
      }
      /****************** Show Picker *********************/
      this.show=function(defaultURL,targetName,targetID,targetValue,width,height,scrolling,sourceObject,targetCode,targetModel,targetPrice,targetUnit){
       if(picker.pickerPad.style.display=="") { picker.hide();return false;}
       if(targetName==undefined) {
        alert("未设置目标对象. \n方法: Picker.show(string 搜索页面URL,obj 目标名称,obj 目标ID,obj 目标Value,Width,Height,obj 点击对象);\n\n搜索页面URL:数据选择页面.\n目标名称:接受返回的名称.\n目标ID:接受返回的ID.\n目标Value:接受返回的值.\n点击对象:点击这个对象弹出picker,默认为目标对象.\n");
        return false;
       }else{  
       picker.targetName=targetName;
       }
       picker.source=picker.targetName;
    if(defaultURL&&picker.pickerFrm.src!=defaultURL){picker.pickerFrm.src="about:blank";picker.pickerFrm.src=defaultURL;}
    if(targetID)picker.targetID=targetID;
    if(targetValue)picker.targetValue=targetValue;
    if(targetModel)picker.targetModel=targetModel;
    if(targetPrice)picker.targetPrice=targetPrice;
    if(targetUnit)picker.targetUnit=targetUnit;
    if(targetCode)picker.targetCode=targetCode;
    if(width){picker.pickerFrm.width=width;}else{picker.pickerFrm.width=400;}
    if(height){picker.pickerFrm.height=height;}else{picker.pickerFrm.height=250;}
    picker.pickerFrm.scrolling="no";
    picker.pickerPad.style.display="";
       //****************调整位置**************//
       var offsetPos=picker.getAbsolutePos(picker.source);//计算对象的位置;
       var calTop=offsetPos.y  + 2;
       var calLeft=offsetPos.x ;   picker.pickerPad.style.pixelLeft=calLeft;
       picker.pickerPad.style.pixelTop=calTop;
      }
      /****************** 计算对象的位置 *************************/
      this.getAbsolutePos = function(el) {
       var r = { x: el.offsetLeft, y: el.offsetTop };
       if (el.offsetParent) {
        var tmp = picker.getAbsolutePos(el.offsetParent);
        r.x += tmp.x;
        r.y += tmp.y;
       }
       return r;
      };
     
      /************** 隐藏面板 *********************/
      this.hide=function(){
       picker.pickerPad.style.display="none";
      }
       this.displayShow=function(){
       picker.pickerPad.style.display="";
      }
      /************** 返回数据 *********************/
      this.pick=function(name,id,value,code,model,price,unitt){
       if(name&&picker.targetName)picker.targetName.value=name;
       if(id&&picker.targetID)picker.targetID.value=id;
       if(value&&picker.targetValue)picker.targetValue.value=value;
       if(code&&picker.targetCode)picker.targetCode.value=code;
       if(model&&picker.targetModel)picker.targetModel.value=model;
       if(price&&picker.targetPrice)picker.targetPrice.value=price;
       if(unitt&&picker.targetUnit)picker.targetUnit.value=unitt;
       picker.hide();
      }
      /************** 从这里开始 *********************/
      this.setup=function(defaultDate){
       picker.addPickerPad();
      }
      picker.setup();
     }
      

  4.   

    使用HttpRequest请求目的页面,然后输出到自己的当前页.
      

  5.   

    返回访问某个URL的结果:

    public string GetURLStringWithStream(string url)
    {
    try
    {
    WebRequest wReq = WebRequest.Create(url);
    WebResponse wResp = wReq.GetResponse();
    Stream respStream = wResp.GetResponseStream();
    StreamReader reader = new StreamReader(respStream, Encoding.Default);
    String respHTML = reader.ReadToEnd();
    wResp.Close();
    return respHTML;
    }
    catch(Exception e)
    {

    return e.ToString();

    } }
      

  6.   

    karykwan(独行者) 提到的 web service 似乎就是解决楼主的这种问题的。可以试试。;)
      

  7.   

    这种情况request和response都是可以做的。
    当然webservice也是可以做,这样做的优势是,其它类型的应用,如winform,其它语言如java开发的程序,也同样可以调用这个搜索的方法。
      

  8.   

    如果是公开允许别人调用的,最好做成WebService。调用方可以选择在服务器端调用或者客户端调用。服务器端调用就是直接在ASP.NET代码中调用此WebService并利用返回结果生成页面,客户端调用就使页面输出到客户端后通过Javascript调用该WebService(需要Atlas来提供调用便利以及服务器端Bridge)然后动态添加内容。
      

  9.   

    xmlhttp 获取远程网页,再用javascript组织dom,你可以下载一个新闻小偷程序参考一下
      

  10.   

    我用isline(缘清)的方法取得url运行结果的还是有问题,   比如说:我用main.aspx包括三个部分,top.ascx,mainpart.ascx,bottom.ascx;top为网页头部(top.htm),bottom为网页尾部(bottom.htm),问题在mainpart部分(mainpart.aspx),mainpart包括一个form表单,而main.aspx也包括一个form,当mainpart部分的表单提交时会出现错误?????????????????为什么啊?怎么搞啊,烦啊!!!!!!!!!
      

  11.   

    错误提示如下:
    Invalid character in a Base-64 string. 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Invalid character in a Base-64 string.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
    [FormatException: Invalid character in a Base-64 string.]
       System.Convert.FromBase64String(String s) +0
       System.Web.UI.LosFormatter.Deserialize(String input)
       System.Web.UI.Page.LoadPageStateFromPersistenceMedium()[HttpException (0x80004005): Invalid_Viewstate
    Client IP: 127.0.0.1
    Port: 4391
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; InfoPath.1)
    ViewState: 省略
    Http-Referer: http://localhost:8080/AoyouNetWeb/BookingEngine/AgentIndex.aspx
    Path: /AoyouNetWeb/BookingEngine/AgentIndex.aspx.]
       System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
       System.Web.UI.Page.LoadPageViewState()
       System.Web.UI.Page.ProcessRequestMain()