惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
M
MIT News - Artificial intelligence
U
Unit 42
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
I
InfoQ
WordPress大学
WordPress大学
H
Help Net Security
D
Docker
B
Blog
腾讯CDC
A
About on SuperTechFans
Recent Announcements
Recent Announcements
雷峰网
雷峰网
有赞技术团队
有赞技术团队
C
Check Point Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - mecn

好久没来了。。。。。。。。。。 2007最全网页设计实用代码(史上最全) zt javascript 客户端验证上传文件是否合法 c# 汉语拼音排序函数 vs2005 ActiveX c# 注意几点! 关于IE非安全更新带来flash和ActivX不能激活的解决办法(zt) NHibernate 学习 (转园子里子两篇关于NHibernate的文章) 将后台数据读取到前台的EXCEL文件中去,用javascript实现,asp.net,javacript(发一个原创) 浅谈图形验证码的识别 用ajax打造和gmail一样的加载进度条显示!(原创) asp.net大页面载入时以进度条显示zt ajax中 同一页面中 UpdatePanel 区别 更新多个区域的关键 timer使用方法 在asp.net Sql server (可以是存储过程)中使用事务回滚 网页一屏到底有多大 1024*768 800*600 网页设计大小 网页设计尺寸 在vs2005中用push方式来用水晶报表,比pull方式好用多了! 去掉VS2005中水晶报表的登录界面(ZT) Visual Studio 2005 IDE 技巧和窍门 得到页面所有的form内对象数值——————为一个控件加一个客户端属性 动态生成表格内容,支持多个textbox,自动生成textboxID,比较好用
从webservice读取string[]至downlist,增加onchange事件,更...
mecn · 2007-03-11 · via 博客园 - mecn

aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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>Untitled Page</title>

 <script language="javascript" type="text/javascript">


function Button1_onclick() {
WebService.getStr(callComplete);
}

function aa()
{
   
var List = document.getElementById("dd1");
   document.getElementById(
"Label1").innerHTML = List.options[List.selectedIndex].value;
}

function callComplete(result)
    
{
         
        
         
var List = document.getElementById("dd1"); 
  
          
for (x=List.options.length-1; x > -1; x--
          
{
              List.remove(
0);
          }

                
          
for(x=0;x<result.length;x++)
          
{      
            
var option = document.createElement("option");
             option.text 
= result[x];
             option.value 
= result[x];
              
if ( window.navigator.appName.toLowerCase().indexOf("microsoft"> -1
                                   List.add(option);  
                                
else
                                   List.add(option, 
null);     
             }
    
    }



    
</script>

</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="WebService.asmx" />
            </Services>
        </asp:ScriptManager>
        <input id="Button1" type="button" value="button" language="javascript" onclick="return Button1_onclick()" />
        <asp:DropDownList ID="dd1" runat="server">
        </asp:DropDownList>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>      
    </form>
</body>
</html>

webservice代码:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Data;/// <summary>
/// WebService 的摘要说明
/// </summary>
/// 
[ScriptService]
[WebService(Namespace 
= "http://tempuri.org/")]
[WebServiceBinding(ConformsTo 
= WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {public WebService () {//如果使用设计的组件,请取消注释以下行 
        
//InitializeComponent(); 
    }
    
    [WebMethod]
    
public string HelloWorld() {
        
return "Hello World";
    }

    [WebMethod]

public string [] getStr()
    {
        
        
return new  string[]  {"Hello World","bbb","cccc"};
    }