C#中有没有类似showModalDialog的东西,或者说c#怎么和Javascript代码进行通信 你说的是客户端IE组件调用的还是ASP.NET的服务器调用? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我提供的是一个服务器端的按钮我希望电击他之后调用一段Javascript代码并且把运行的结果返回给客户端Javascript代码调用showModalDialog,谈出另一个叶面在塔利便可以进行一些操作 <!-- 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事件这样就可以在客户端调用 1.如果希望结构化比较好(三层结构),可以采用WebService的方法,Ms出了一个WebService.htc,它可以解决你这个问题。但是这种方法你必须提供WebService的服务器段。2.如果要简单,可以使用不可见的IFrame,有IFrame内的叶面负责数据载入工作。这样两种方法主要考虑OnClick不会导致叶面重画。 用类似以下代码就可以:Page.RegisterStartupScript("MsgBox", "<script language=javascript> alert('你点击了按钮!')</script>");格式:Page.RegisterStartupScript(key, "<script language=javascript> 脚本代码 </script>"); try...catch...与if...else...哪个效率高些 C# winform怎么显示时钟 最简单的if语句出错了,不知道为什么 一个关于Jquery ajax 的问题 急急急 郁闷我3天了?各位大虾帮忙一下 关于“推”模式下,带有子报表的水晶报表怎样过滤重复的数据? UP有分 图像识别 ACDSee是用什么写的,在C#里怎么实现类似的RGB修改功能。 C#是不是不如JAVA啊? 如何在水晶报表中打印一个变量的值??? 请教:如何计算字符串的显示长度? 知道www.yahoo.com,如何知道对于的IP地址? 问一个设计界面的问题?
我希望电击他之后调用一段Javascript代码
并且把运行的结果返回给客户端
Javascript代码调用showModalDialog,谈出另一个叶面
在塔利便可以进行一些操作
<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事件这样就可以在客户端调用
Page.RegisterStartupScript(key, "<script language=javascript>
脚本代码 </script>");