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
    }
    }

  • 相关阅读:
    iOS UITextField 设置内边距
    营造积极的OKR环境
    管理者的五项基本活动
    如何在团队中让OKR深入人心
    项目管理文化:营造积极氛围的里程碑
    OKR文化:用SMART原则量化目标
    成功落地OKR的要诀
    培养一支有 OKR 思想的管理团队
    如何成为一个成功的会议领导者
    项目管理文化:开展有效的总结会议
  • 原文地址:https://www.cnblogs.com/gzh4455/p/2199143.html
Copyright © 2011-2022 走看看