如何将html代码写入json

如何将html代码写入json

本文介绍了如何将html代码写入json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以回复我的问题



can any one reply my que

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
    <script type="text/javascript">

        $(function () {
            $("[id*=Button1]").click(function () {
                var obj = {};
                obj.username = $.trim($("[id*=TextBox1]").val());
                obj.countryid = $.trim($("[id*=TextBox2]").val());
                 obj.isactive = $.trim($("[id*=TextBox3]").val());
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/GetValues",
                    data: JSON.stringify(obj),
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (r) {
                        alert(r.d);
                        document.getElementById('lblmsg').value = r.d;
                    }
                });
                return false;
            });
        });
    </script>
    <style type="text/css">
        .auto-style1
        {
            height: 192px;
            width: 646px;
        }
        .auto-style2
        {
            height: 26px;
        }
        .auto-style3
        {
            height: 32px;
        }
    </style>
</head>
<body>
<form id="form1" runat="server">
<div>

<table ="center" class="auto-style1">
<tr>
<td>UserName</td>
<td>
    <asp:TextBox ID="TextBox1" runat="server" Height="26px" style="margin-bottom: 0px" Width="144px"></asp:TextBox>
    </td>
<td>
    &nbsp;</td>
<td> </td>
</tr>
<tr>
<td>CountryId </td>
<td>
    <asp:TextBox ID="TextBox2" runat="server" Height="34px" Width="144px"></asp:TextBox>
    </td>
<td>
    &nbsp;</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2">IsActive</td>
<td class="auto-style2">
    <asp:TextBox ID="TextBox3" runat="server" Height="24px" Width="147px"></asp:TextBox>
    </td>
<td class="auto-style2">&nbsp;</td>
</tr>
<tr>
<td> </td>
<td class="auto-style3">
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </td>
<td class="auto-style3">
</td>
<td class="auto-style3"> </td>
</tr>
<tr>
<td>Result:</td>
<td>
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
    </td>
<td>
    &nbsp;</td>
<td> </td>
</tr>
</table>

</div>
</form>
</body>
</html>

推荐答案




这篇关于如何将html代码写入json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 22:31