• 示例


    >> 接前文 "示例 - 如何在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. 运行~!

    相关阅读:

  • 相关阅读:
    JVM工作原理--垃圾收集
    并发编程之单例模式
    设计模式之动态代理
    UML类图基础
    CAP理论的理解
    Dubbo RPC调用参数校验---错误message自动返回
    ELK日志分析系统搭建
    Kafka原理及应用(一)
    HTTPS的原理
    Maven 生命周期的概念(指令默认顺序执行)
  • 原文地址:https://www.cnblogs.com/iamzyf/p/3492712.html
Copyright © 2020-2023  润新知