惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
The Cloudflare Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
L
LangChain Blog
Recent Announcements
Recent Announcements
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
V
V2EX
I
InfoQ
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
H
Help Net Security
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - Ivan Zou

示例 - 17行代码实现一个简单高效的多线程蜘蛛程序 示例 - 10行代码在C#中获取页面元素布局信息 Spider Studio 新版本 (20140225) - 设置菜单调整 / 提供JQueryContext布局相关的方法 示例 - 如何在NodeJS中调用SS生成的DLL 示例 - 25行代码等价实现 - 借助Nodejs在服务端使用jQuery采集17173游戏排行信息 Spider Studio 新版本 (码年吉祥版) - 浏览器视图 / 脚本库上线! 分享: 利用Readability解决网页正文提取问题 分享一个天气历史数据的采集脚本 分享 - Hybrid 开发将博客园集成到自己的网站中 - 效果高大上 :) Spider Studio 新版本 (20140109) - 修复浏览器对部分网页不支持的BUG Spider Studio 新版本 (20140108) - 优化设置菜单 / 生成程序集支持版本号 示例 - 数据仓库的妙用 Spider Studio 界面功能布局 C# 脚本代码自动登录淘宝获取用户信息 API - 使用数据仓库 - 基础篇 示例 - 如何在多线程中应用SpiderStudio生成的DLL? 示例 - 如何在Console应用程序中应用SpiderStudio生成的DLL? C#中另辟蹊径解决JSON / XML互转的问题 Spider Studio 新版本 (x-mas) - 可以引入第三方程序集, 可以将脚本生成为DLL
示例 - 如何在ASP.NET中应用Spider Studio生成的DLL?
Ivan Zou · 2013-12-26 · via 博客园 - Ivan Zou

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

相关阅读: