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

หาขนาดไฟล์ด้วย FileInfo



Dim fileSize As String

fileSize = New IO.FileInfo(Server.MapPath("/download/files/form_bantuek (1).doc")).Length

If fileSize >= 1048576 Then
   fileSize = FormatNumber((fileSize / 1024) / 1024, 2) & "MB."
ElseIf fileSize > 0 Then
   fileSize = FormatNumber(fileSize / 1024, 2) & "KB."

End If


วันจันทร์ที่ 21 กันยายน พ.ศ. 2558

ซ่อนและแสดง div ด้วย JavaScript เมื่อมีการคลิกที่รูปภาพ

<img id="clickMeId" src="Icons/note_add.png" onclick="show('comment')"/>
<div id="comment" style="float:left;display:none;">
    <textarea name="textfield6" cols="30" rows="2" id="Textarea1" class="text"></textarea>
    <a href="#" class="buttonintable">Submit</a>
</div>

<script type="text/javascript">
    function show(target){
    document.getElementById(target).style.display = 'block';
    document.getElementById("clickMeId").style.display = 'none';
    }
    function hide(target){
    document.getElementById(target).style.display = 'none';
    document.getElementById("clickMeId").style.display = 'block';
    }

</script>

Repeater Item Command เพื่อเรียกใช้ Control ต่างๆ ใน Repeater

Protected Sub Repeater2_ItemCommand(source As Object, e As RepeaterCommandEventArgs) Handles Repeater2.ItemCommand
        Dim rI As RepeaterItem = Me.Repeater2.Items(e.Item.ItemIndex)
        Dim txtReply As TextBox = rI.FindControl("txtReply")
        Dim ltrReply As Literal = rI.FindControl("ltrReply")
        Dim btnReply As LinkButton = rI.FindControl("btnReply")

        If e.CommandName = "btnReply" Then
            ltrReply.Text = txtReply.Text
        End If
        'If btnReply.CommandName = "" Then

        'End If

    End Sub

**********************************************
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:Literal ID="ltrReply" runat="server"></asp:Literal>
<asp:TextBox ID="txtReply" runat="server" TextMode="MultiLine" </asp:TextBox>
<asp:LinkButton ID="btnReply" CommandName ="btnReply" runat="server">Post Comment</asp:LinkButton>
</ItemTemplate>
</asp:Repeater>

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

เติมส่วนที่ขาดหายไปของโปรแกรมคำนวณสูตรคูณต่อไปนี้ให้สมบูรณ์และถูกต้องที่สุด


Public (1)___________ Form1

   
     Private (2)__________ Button1_(3)__________ (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim total As (4)__________

        Dim i As (5)__________

        Dim s As (6)__________

        For i = 1 To (7)__________

            total = Val(TextBox1.Text) * i

            (8)__________ = s & TextBox1.Text & " x " & i & " = " & total & vbCrLf

        Next

        (9)__________(s)

    End Sub


End (10)__________

ให้ออกแบบวิธีการแก้ไขปัญหาโดยพิจารณาจากผังงานโปรแกรม อย่างใดอย่างหนึ่ง เพื่อแก้ไขปัญหาตามโจทย์ที่กำหนดให้

จากผังงาน กำหนดค่าตัวแปร  จงใช้ตอบคำถาม


2.1       กำหนดให้    A = 10  ,  B =  15                ตอบ      A  = ?   , B = ?   , C= ?   , D = ?
2.2       กำหนดให้    
A = 15  ,  B =  10                ตอบ       A  = ?   ,  B = ?   , C= ?   ,   D = ?
2.3       กำหนดให้
   A = 20  ,  B =  5                  ตอบ      A  = ?   , B = ?   , C= ?   , D = ?
2.4       กำหนดให้
   A = 10  ,  B =  15                ตอบ       A  = ?   ,  B = ?   , C= ?   ,   D = ?
2.5       กำหนดให้
   B = 10  ,  D =  15                ตอบ      A  = ?   , B = ?   , C= ?   , D = ?


 จากชุดคำสั่ง กำหนดค่าตัวแปร  จงใช้ตอบคำถาม

3.1       กำหนดให้  A1 = 1    ,  B1 =  5              ตอบ      A  = ?     , B =  ?   , Sum  =  ?    
3.2       กำหนดให้  A1 = 5    ,  B1 =  10            ตอบ      A  = ?     , B =  ?   , Sum  =  ?   
3.3
      กำหนดให้  A1 = 10  ,  B1 =  5              ตอบ      A   = ?    , B = ?    , Sum  =  ?   
3.4
      กำหนดให้  A1 = 5   ,  B1  =  5              ตอบ      A   = ?    , B = ?     , Sum =  ?   
3.5
      กำหนดให้  A1 = 5   ,  B1  =  11            ตอบ      A   = ?    , B = ?     , Sum =  ?   

 

ปลายทางของการศึกษา คืออุปนิสัยที่ดีงาม

การใช้ 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>

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

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