日期:2013-10-16  浏览次数:20483 次

好了,至此,我们的webservice就完成了,大家可能不满了,还是没实现无刷新嘛,别急,这是客户端的事。下面我们就来做这项工作。
一般来说我们完全可以做一个html页面,而不用server page,但为了顺便说明怎样做组件,我决定作一个server control,先来看一下代码
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;

namespace Michael.Web.UI.Controls
{
    /// <summary>
    /// Summary description for chat.
    /// </summary>
    [DefaultProperty("Text"),
        ToolboxData("<{0}:chat runat=server></{0}:chat>")]
    public class chat : System.Web.UI.WebControls.Table
    {
        private string doc;
        private string text;
        [Bindable(true),
        Category("Appearance"),
        DefaultValue("")]
        public string Text
        {
            get
            {
                return text;
            }

            set
            {
                text = value;
            }
        }

        /// <summary>
        /// Render this control to the output parameter specified.
        /// </summary>
        /// <param name="output"> The HTML writer to write out to </param>
        protected override void Render(HtmlTextWriter output)
        {
            // The script block is written to the client
            output.Write(doc);
            
            base.Render(output);
        }

        private string Serviceurl = "http://localhost/chat/ChatWebService.asmx?WSDL";
        [Bindable(true),
        Category("WebServiceProperty"),
        DefaultValue("http://localhost/chat/ChatWebService.asmx?WSDL")]
        public string ServiceURL
        {
            get
            {
                return Serviceurl;
         &