วันอาทิตย์ที่ 20 กันยายน พ.ศ. 2558

การใช้ XMLDocument เพื่อเรียกค่าข้อมูลในรูปแบบ XML

Imports System.Xml
----------------------------------------------------------------------------------------------------------
Function doGetXML(AuctionNote_reply As String) As String
        Dim xml As String = <replys>
                                <reply id='1'>
                                    <img>aaaa@gmail.com</img>
                                    <usertype>ลูกค้า</usertype>
                                    <curdate>2014-09-22 20:54:17.460</curdate>
                                    <detial>ค่ะ ขอบคุณค่ะ ส่งให้ทางไหนค่ะ คือ เพิ่งใช้ระบบนี้เหมือนกันค่ะ</detial>
                                </reply>
                                <reply id='2'>
                                    <img>bbbb@hotmail.com</img>
                                    <usertype>นักแปล</usertype>
                                    <curdate>2014-09-22 20:54:17.460</curdate>
                                    <detial>ขอบคุณที่ไว้วางใจครับ</detial>
                                </reply>
                            </replys>

        Dim doc As New XmlDocument
        doc.LoadXml(xml)

        Dim node As XmlNode = doc.SelectSingleNode("replys")
        If node IsNot Nothing Then
            Dim addStatus As String = node.InnerText.Trim()
            Dim addNode As XmlNode = doc.SelectSingleNode("replys")
            Dim htmlX As New StringBuilder

            For Each ele As XmlElement In addNode.ChildNodes
                Dim img As String = ele.SelectSingleNode("img").InnerText   'ele.InnerText
                Dim detial As String = ele.SelectSingleNode("detial").InnerText
                Dim usertype As String = ele.SelectSingleNode("usertype").InnerText
                Dim curdate As String = ele.SelectSingleNode("curdate").InnerText
            Next

        End If
    End Function

วันศุกร์ที่ 11 กันยายน พ.ศ. 2558

ไม่ให้คลิกขาว ลากดำ ในหน้าเพจ

<script language=JavaScript>
<!--

    //Disable right mouse click Script
    //By Maximus ( maximus@nsimail.com) w/ mods by DynamicDrive
    //For full source code, visit http://www.dynamicdrive.com

    var message = "ขออภัย!";

    ///////////////////////////////////
    function clickIE4() {
        if (event.button == 2) {
            alert(message);
            return false;
        }
    }

    function clickNS4(e) {
        if (document.layers || document.getElementById && !document.all) {
            if (e.which == 2 || e.which == 3) {
                alert(message);
                return false;
            }
        }
    }

    if (document.layers) {
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown = clickNS4;
    }
    else if (document.all && !document.getElementById) {
        document.onmousedown = clickIE4;
    }

    document.oncontextmenu = new Function("alert(message);return false")

    // -->

//Disable select-text script (IE4+, NS6+)
function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}

</script>

วันอาทิตย์ที่ 23 สิงหาคม พ.ศ. 2558

ทำกล่องข้อความแจ้งเตือนแบบ Growl ด้วย Bootstrap




















<button type="button" class="btn btn-sm btn-success btn-growl" data-growl="success"><i class="fa fa-check fa-fw"></i> Success</button>
<button type="button" class="btn btn-sm btn-info btn-growl" data-growl="info"><i class="fa fa-info fa-fw"></i> Info</button>
<button type="button" class="btn btn-sm btn-warning btn-growl" data-growl="warning"><i class="fa fa-exclamation-triangle fa-fw"></i> Warning</button>
<button type="button" class="btn btn-sm btn-danger btn-growl" data-growl="danger"><i class="fa fa-times fa-fw"></i> Danger</button>
     
        <script>
            /* Grawl Notifications with Bootstrap-growl plugin, check out more examples at http://ifightcrime.github.io/bootstrap-growl/ */
            $('.btn-growl').on('click', function () {
                var growlType = $(this).data('growl');

                $.bootstrapGrowl('<h4>Hi there!</h4> <p>This is another notification!</p>', {
                    type: growlType,
                    delay: 2500,
                    allow_dismiss: true
                });

                $(this).prop('disabled', true);
            });

        </script>

ลากไฟล์เพื่ออัพโหลด โดยใช้ Dropzone js + Asp.net























<!--  File Name : drop.html -->
<meta charset="utf-8">

<title>Dropzone simple example</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://rawgit.com/enyo/dropzone/master/dist/dropzone.js"></script>
<link rel="stylesheet" href="https://rawgit.com/enyo/dropzone/master/dist/dropzone.css">


<div id="dZUpload" class="dropzone">
         <div class="dz-default dz-message">Upload File</div>
</div>


<hr />

 <script type="text/javascript">

     $(document).ready(function () {

         Dropzone.autoDiscover = false;

         //Simple Dropzonejs
         $("#dZUpload").dropzone({
             url: "/file-upload/hn_SimpeFileUploader.ashx",
             addRemoveLinks: true,
             success: function (file, response) {
                 var imgName = response;
                 file.previewElement.classList.add("dz-success");
                 console.log("Successfully uploaded :" + imgName);
             },
             error: function (file, response) {
                 file.previewElement.classList.add("dz-error");
             },maxFiles:1,
         init: function() {
             this.on("maxfilesexceeded", function(file) {
                 this.removeAllFiles();
                 this.addFile(file);
             });
         }
         });
     });

</script>

************************* hn_SimpeFileUploader.ashx ******************************
Imports System.Web
Imports System.Web.Services

Public Class hn_SimpeFileUploader
    Implements System.Web.IHttpHandler



    Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest
        context.Response.ContentType = "text/plain"

        Dim dirFullPath As String = HttpContext.Current.Server.MapPath("~/file-upload/upload-target/")
        Dim files As String()
        Dim numFiles As Integer
        files = System.IO.Directory.GetFiles(dirFullPath)
        numFiles = files.Length
        numFiles = numFiles + 1

        Dim str_image As String = ""
        Dim i As Integer
        For Each s As String In context.Request.Files
            i += 1
            Dim file As HttpPostedFile = context.Request.Files(s)
            '  int fileSizeInBytes = file.ContentLength;
            Dim fileName As String = file.FileName
            Dim fileExtension As String = file.ContentType

            If Not String.IsNullOrEmpty(fileName) Then
                'fileExtension = IO.Path.GetExtension(fileName)
                'str_image = "MyPHOTO_" & i & fileExtension
                Dim pathToSave_100 As String = HttpContext.Current.Server.MapPath("~/file-upload/upload-target/") & fileName 'str_image
                file.SaveAs(pathToSave_100)
            End If
        Next
        context.Response.Write(str_image)
    End Sub

    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

การใช้ WebClient สำหรับเรียก URL

Dim _url As String = " https :// www . MyDomain . com /?q=ทดสอบ " Dim wc As New System . Net . WebClient () wc . Encodin...