zoukankan      html  css  js  c++  java
  • 示例

    >> 接前文 "示例 - 如何在Console应用程序中应用SpiderStudio生成的DLL?", 将其运用到ASP.NET中:

    1. 创建WebApplication项目, 引入www.utilities_online.info.XmlJsonConverter.dll

    2. 设置Target Framework为: .NET Framework 4

    3. 在Default.aspx上拖放控件

    HTML:

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" AspCompat="true" %>
    
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <table>
        <tr><td>XML</td><td></td><td>JSON</td></tr>
            <tr>
                <td>
                    <input id="xml" style="445px;height:320px" type="text" runat=server/>
                </td>
                <td>
                    <asp:Button ID="toxml" runat="server" Text="&lt;-" onclick="toxml_Click" />
                    <br />
                    <asp:Button ID="tojson" runat="server" Text="-&gt;" onclick="tojson_Click" />
                </td>
                <td>
                    <input id="json" style="445px;height:320px"  type="text" runat=server />
                </td>
            </tr>
        </table>
    </asp:Content>

    4. 将Default.aspx设置为: AspCompat="true"

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" AspCompat="true" %>

    - 这样做的目的是将页面的线程模型改成单线程模式, 从而能够支持activeX控件的调用. 

    5. 编写后台代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using www.utilities_online.info;
    
    namespace WebApplication1
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
            }
    
            protected void toxml_Click(object sender, EventArgs e)
            {
                xml.Value = new XmlJsonConverter().Json2Xml(json.Value);
            }
    
            protected void tojson_Click(object sender, EventArgs e)
            {
                json.Value = new XmlJsonConverter().Xml2Json(xml.Value);
            }
        }
    }

    6. 运行~!

    相关阅读:

  • 相关阅读:
    全局变量和局部变量
    单例模式i
    高阶函数
    闭包和内存管理
    用python 写网络爬虫--零基础
    robots.txt 文件是什么? 如何获取
    Python: NLTK几个入门函数
    nltk book的下载
    nltk 环境安装( WINDOWS 7 32位 环境下)
    遇到问题
  • 原文地址:https://www.cnblogs.com/iamzyf/p/3492712.html
Copyright © 2011-2022 走看看