<%@ Page Title="" Language="C#"   AutoEventWireup="true" CodeBehind="Kb_New.aspx.cs" Inherits="Kbase.admin.New_Kb" %>
 
<!DOCTYPE html> 
<html >
<head runat="server">
    <title></title> 
     <script src="../javascript/jquery-1.9.1.min.js"></script>
     <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" />
     <script src="../bootstrap/js/bootstrap.min.js"></script>
     <script src="../javascript/layer/layer.js"></script>
     <script src="../javascript/common.js"></script> 
    <link href="../javascript/pandao-markdown/css/editormd.min.css" rel="stylesheet" />
    <script src="../javascript/pandao-markdown/editormd.js"></script>
  
    <style>
        .btn,.form-control{ border-radius:0px }
    </style>
</head>
<body style="margin:auto 5px;">
 
    <form id="form1" runat="server" autocomplete="off">
    <div>
         
        <div style="margin:10px auto">
           <div>
               <b>标题</b>

               &nbsp;<span style="float:right">
                   <ul class="breadcrumb">
                   <asp:Literal runat="server" ID="lbl_nav"></asp:Literal>
                       </ul>

                     </span>
           </div>
 
            
             <input type="text"  class="form-control" id="name" value="<%=title %>" />
           </div>
            <div id="test-editormd">
               <textarea style="display:none;"><%=contents %></textarea>
            </div>
        


  
        <script type="text/javascript">
            var testEditor;

            $(function () {
                testEditor = editormd("test-editormd", {
                    width: "100%",
                    height:520,
                    placeholder: "",
                    lineNumbers:true,
                    path: "../javascript/pandao-markdown/lib/", 
                    toolbarIcons: function () { 
                        return ["bold", "quote", "|", "h3", "h4", "h5", "h6", "list-ul", "list-ol", "|", "link", "image", "|", "code", "code-block", "table"]
                    },

                    imageUpload: true,
                    imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                    imageUploadURL: "save_img.aspx",
                    saveHTMLToTextarea : true

                    

                }); 
            });
        </script>


        <asp:PlaceHolder runat="server" ID="ph_add">

      
        <div style="text-align:center">

              <input type="button"  value="添加" 
                  class="btn btn-primary"
                  onclick="add();" 
          />

            &nbsp;  &nbsp;  &nbsp;  &nbsp;
       


        </div>

              </asp:PlaceHolder>


          <asp:PlaceHolder runat="server" ID="ph_edit">

      
        
        <div style="text-align:center">

              <input type="button"  value="更新" 
                  class="btn btn-primary"
                  onclick="update();" 
          />

        

        </div>
   </asp:PlaceHolder>

    <script>

        function add()
        {
            var title =encodeURIComponent ($("#name").val());
            var cnt= encodeURIComponent ( testEditor.getMarkdown());
            var catid = "<%=Request.QueryString["catid"]%>";
            var t = "add";
            
              
            $.post("ajax/news.aspx",
                { title: title, cnt: cnt ,catid:catid,t:t },
                function (result) {
                    alert("添加成功");
                    window.location = "Kb_Lists.aspx?id="+catid;
                       
                });  

        }


        function update() {
            var title = encodeURIComponent($("#name").val());
            var cnt = encodeURIComponent(testEditor.getMarkdown());
            var id = "<%=id%>";
            var catid = "<%= catid %>";
            var t = "update";


            $.post("ajax/news.aspx",
                { title: title, cnt: cnt, id: id, t: t },
                function (result) {
                    alert("添加成功");
                    window.location = "Kb_Lists.aspx?id=" + catid;

                });

        }


    </script>

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