zoukankan      html  css  js  c++  java
  • 异步Web Part

    代码如下:

    Calling Web Service
    using System;
    using System.Runtime.InteropServices;
    using System.Web.UI;


    namespace WebPartCollection
    {
    [Guid("d2b37a6c-650c-4ef4-962c-85297f15b0b5")]
    public class AsyWebServiceWebPart : System.Web.UI.WebControls.WebParts.WebPart, ICallbackEventHandler
    {
    public AsyWebServiceWebPart()
    {
    }

    protected override void CreateChildControls()
    {
    base.CreateChildControls();
    }
    protected override void OnInit(EventArgs e)
    {

    base.OnInit(e);
    if (Page.IsPostBack)
    {
    return;
    }
    string serverCallJs = Page.ClientScript.GetCallbackEventReference(this, "",
    "AsyWebServiceWebPart_Callback", "", "AsyWebServiceWebPart_Callback", true);

    string clientCallbackJs = "function AsyWebServiceWebPart_Callback(returnValue,context)"+
    "{document.getElementById('"+this.ClientID+"_content').innerHTML=returnValue;}\n";

    Page.ClientScript.RegisterStartupScript(this.GetType(), "loadWether", clientCallbackJs + serverCallJs + ";\n", true);
    }
    protected override void Render(HtmlTextWriter writer)
    {
    writer.Write("<div id='" + this.ClientID + "_content' style='text-align:center'>loading…</div>");
    }


    #region ICallbackEventHandler 成员

    string GetCallbackResult()
    {
    WebXML.WeatherWebService weathreWS = new CodeArt.SharePoint.WebXML.WeatherWebService();
    string[] data = weathreWS.getWeatherbyCityName("上海");
    return data[5] + "<br/>" + data[6] + "<br/>" + data[7];
    }

    void RaiseCallbackEvent(string eventArgument)
    {

    }

    #endregion
    }
    }

  • 相关阅读:
    ☀【布局】
    _#【CSS3】
    _#minheight
    【其它】引入css
    【css3】url
    鼠标闲置一段时间后自动隐藏
    图解SQLServer2005获取WebService数据
    Oracle字符串字段内的字符排序
    一个c#读取扫雷内存的demo
    sqlserver使用bcp分解字符串
  • 原文地址:https://www.cnblogs.com/gzh4455/p/2199143.html
Copyright © 2011-2022 走看看