你说的是客户端IE组件调用的还是ASP.NET的服务器调用?

解决方案 »

  1.   

    我提供的是一个服务器端的按钮
    我希望电击他之后调用一段Javascript代码
    并且把运行的结果返回给客户端
    Javascript代码调用showModalDialog,谈出另一个叶面
    在塔利便可以进行一些操作
      

  2.   

    <!-- File 1: ShowPopup.html --//>
    <HTML>
    <HEAD>
    <TITLE>Test menus</TITLE>
    <SCRIPT SRC="Popup.js"></SCRIPT>
    <SCRIPT>
     var myMenu = new menu("Test");
     var item1 = new menuItem("Hello","http://au.yahoo.com");
     var mySub = new menu("Sub menu");
     var item2 = new menuItem("Item 2","http://au.yahoo.com");
     mySub.addItem(item2); myMenu.addItem(item1);
     myMenu.addItem(mySub);
    </SCRIPT>
    <STYLE>
     .menubuttonovr{
       border-top: 1pt solid white;
       border-left: 1pt solid white;
       border-bottom: 1pt solid gray;
       border-right: 1pt solid gray;
       cursor: hand;
     } .menubutton{
       border: 1pt solid #C0C0C0;
       cursor: hand;
     }
    </STYLE>
    </HEAD>
    <BODY bgColor="#C0C0C0" onload="doIt()">
    <SPAN onclick="myMenu.show(this.offsetLeft+2, this.offsetHeight + this.offsetTop)" CLASS="menubutton">Show It</SPAN>
    </BODY>
    </HTML><!-- File 2: Popup.js //-->
    var theParent = null;
    function doIt(){
     if(document.parentWindow.parent.theParent){
       theParent = document.parentWindow.parent.theParent;
     }else{
       theParent = window;
     }
    }
    var oPopup = createPopup();
    var cItem = null;function menu(Caption){
     this.caption = Caption;
     this.menuItems = new Array();
     this.addItem = addItem;
     this.itemType = "MENU";
     this.show = showIt;
    }function menuItem(Caption, action){
     this.caption = Caption;
     this.action = action;
     this.itemType = "MENUITEM";
    }function addItem(itm){
     this.menuItems[this.menuItems.length] = itm;
    }function unhilite(obj){
     if(obj != null){
       obj.style.background = "#C0C0C0";
       obj.style.color = "black";
     }
    }function unhiliteCItem(){
     if(cItem != null){
       cItem.style.background = "#C0C0C0";
       cItem.style.color = "black";
     }
    }function hilite(obj){
     obj.style.background = "navy";
     obj.style.color = "white";
    }function showIt(x,y){
     var s = ""; js = "";
     for(var i=0; i < this.menuItems.length; i++){
       if(this.menuItems[i].itemType == "MENU"){
         s += "<SPAN STYLE=\"width: 100%;\" onmouseover=\"oPopup.hide();unhiliteCItem();cItem=this;hilite(this);menu" + i + ".show(this.offsetWidth,this.offsetTop);\">" + this.menuItems[i].caption + "</SPAN>";
         js += buildMenuJS(this.menuItems[i],"menu" + i);
       }else{
         s += "<SPAN STYLE=\"width: 100%;\" onmouseover=\"oPopup.hide();unhilite(cItem);cItem=this;hilite(this);\" onclick=\"theParent.document.location = ('" + this.menuItems[i].action + "')\">" + this.menuItems[i].caption + "</SPAN>";
       }
     }
     oPopup.document.open();
     oPopup.document.write("<HTML><HEAD><SCRIPT SRC=\"Popup.js\"></SCRIPT>");
     oPopup.document.write("<SCRIPT>\n" + js + "\n</SCRIPT></HEAD>");
     oPopup.document.write("<BODY onload=\"doIt()\">" + s + "</BODY></HTML>");
     oPopup.document.close();
     oPopup.document.body.scroll = "no";
     oPopup.document.body.leftMargin = 2;
     oPopup.document.body.topMargin = 2;
     var theSty = oPopup.document.body.style;
     theSty.background = "#C0C0C0";
     theSty.borderLeft = "1pt solid white";
     theSty.borderTop = "1pt solid white";
     theSty.borderBottom = "1pt solid gray";
     theSty.borderRight = "1pt solid gray";
     oPopup.show(x,y,100,(20*this.menuItems.length)+4,document.body);
    }function buildMenuJS(theMenu, menuName){
     var s = menuName + " = new menu('" + theMenu.caption + "');\n";
     for(var i=0; i < theMenu.menuItems.length; i++){
       if(theMenu.menuItems[i].itemType == "MENUITEM"){
         s += menuName + ".addItem(new menuItem('" + theMenu.menuItems[i].caption + "','" + theMenu.menuItems[i].action + "'));\n";
       }else{
         s += buildMenuJS(theMenu.menuItems[i],menuName + "_" + i);
         s += menuName + ".addItem(" + menuName + "_" + i + ");\n";
       }
     }
     return s;

    服务器端的按钮,可以进入html编辑区中,写onclick事件这样就可以在客户端调用
      

  3.   

    1.如果希望结构化比较好(三层结构),可以采用WebService的方法,Ms出了一个WebService.htc,它可以解决你这个问题。但是这种方法你必须提供WebService的服务器段。2.如果要简单,可以使用不可见的IFrame,有IFrame内的叶面负责数据载入工作。这样两种方法主要考虑OnClick不会导致叶面重画。
      

  4.   

    用类似以下代码就可以:Page.RegisterStartupScript("MsgBox", "<script language=javascript> alert('你点击了按钮!')</script>");格式:
    Page.RegisterStartupScript(key, "<script language=javascript> 
    脚本代码 </script>");