二维码,条形码,显示页面

@{
Layout = null;
}

<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script>
    function DoQr() {
        var text = $("#txt_QrStr").val();
        var width = $("#txt_QrWidth").val();
        var height = $("#txt_QrHeight").val();
        $.get("/Code/GetQrCode", { content: text, width: width, height: height }, function (data) {
            if (data != "") {
                console.log(data);
                $("#Img_QrCode").attr("src", "data:image/jgp;base64," + data)
            }
            else {
                alert("生成失败");

            }
        })
    }

    function DoBar() {
        var text = $("#txt_BarStr").val();
        var width = $("#txt_BarWidth").val();
        var height = $("#txt_BarHeight").val();
        $.get("/Code/GetBarCode", { content: text, width: width, height: height }, function (data) {
            if (data != "") {
                console.log(data);
                $("#Img_BarCode").attr("src", "data:image/jgp;base64," + data)
            }
            else {
                alert("生成失败");

            }
        })
    }
</script>


    <table>
        <tr>
            <td><img id="Img_QrCode" src="" alt="" /></td>
            <td><img id="Img_BarCode" src="" alt="" /></td>
        </tr>
        <tr>
            <td>
                内容:<input id="txt_QrStr" type="text" /><br />
                宽:<input id="txt_QrWidth" type="text" /><br />
                高:<input id="txt_QrHeight" type="text" /><br />
                <input id="btn_QrCode" type="button" value="生成二维码" onclick="DoQr()" />
            </td>
            <td>
                内容:<input id="txt_BarStr" type="text" /><br />
                宽:<input id="txt_BarWidth" type="text" /><br />
                高:<input id="txt_BarHeight" type="text" /><br />
                <input id="btn_BarCode" type="button" value="生成条形码" onclick="DoBar()" />
            </td>
        </tr>
    </table>
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页