Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > .NET Framework > Forum > สอบถามเกี่ยวกับการเก็บ dropdown value ใน cookies ครับ


 

[.NET] สอบถามเกี่ยวกับการเก็บ dropdown value ใน cookies ครับ

 
Topic : 125485



โพสกระทู้ ( 37 )
บทความ ( 0 )



สถานะออฟไลน์



คือต้องการเก็บค่าที่ได้จากการ เลือก dropdown ลง cookies ครับ แต่ค่าที่ได้มันผิด
เช่นถ้าเลือก TH ค่า cookies ที่ได้จะเป็น EN ถ้าเลือก EN ค่า cookies ที่ได้จะเป็น TH
ไม่แน่ใจว่าทำตรงไหนผิด ใครทราบรบกวนช่วยแนะนำด้วยครับ ขอบคุณครับ


Code (VB.NET)
1.<form id="form1" runat="server">
2.  <div>
3.  <asp:DropDownList ID="ddlLanguages" runat="server" AutoPostBack="true"  CssClass="ddlLang">
4.      <asp:ListItem Text="TH" Value="th-TH" />
5.      <asp:ListItem Text="EN" Value="en-us" />
6.  </asp:DropDownList>
7.  </div>
8.  </form>



Code (VB.NET)
01.Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
02.      Dim testlangCookie As HttpCookie = New HttpCookie("testlangCookie")
03.      If Not Page.IsPostBack Then
04.          If IsNothing(Request.Cookies("testlangCookie")) Then
05.              testlangCookie("testlangCookie") = "th-TH"
06.              Response.Cookies.Add(testlangCookie)
07.              testlangCookie.Expires = DateTime.Now.AddDays(1)
08.          End If
09.      Else
10.          testlangCookie("testlangCookie") = ddlLanguages.SelectedValue
11.          Response.Cookies.Add(testlangCookie)
12.          testlangCookie.Expires = DateTime.Now.AddDays(1)
13.      End If
14.      If Request.Cookies("testlangCookie")("testlangCookie") Is Nothing Then
15.          ddlLanguages.SelectedValue = "th-TH"
16.      Else
17.          ddlLanguages.SelectedValue = testlangCookie("testlangCookie")
18.      End If
19.      Response.Write("cookies value is " & Request.Cookies("testlangCookie")("testlangCookie"))
20.  End Sub




Tag : .NET, Web (ASP.NET), VB.NET, Windows



ประวัติการแก้ไข
2016-11-23 17:06:04
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-11-23 17:05:25 By : kornraphat View : 990 Reply : 8
 

 

No. 1



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Cookies มันจะต้อง Refresh ก่อน 1 ครั้งครับ ถึงจะอ่านค่าได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-24 18:06:13 By : mr.win
 

 

No. 2

Guest


วิธีแก้ไขทำเป็น Class (นิสัย) เก็บเอาไว้ (หลบหลีก Events PostBack/Not PostBack)
Code (VB.NET)
001.Imports System.Web
002.Imports System.Collections
003.Imports System.Collections.Specialized
004.Imports System.Web.Security 'Add Referance System.Web.Extentions
005. 
006.Public Class myCookies
007. 
008.    Private Shared _Current As HttpContext = HttpContext.Current
009.    Private Shared _cookieName As String = "__หน้าฮี__"
010.    Private Shared _data As HybridDictionary = Nothing
011. 
012.    Sub New()
013.    End Sub
014. 
015.    Sub New(ByVal cookieName As String)
016.        _cookieName = cookieName
017.    End Sub
018. 
019.    Public Sub InsertValue(ByVal subKey As String, ByVal subValue As String)
020.        If _Current.Response.Cookies(_cookieName) IsNot Nothing Then
021.            Dim aCookie As HttpCookie = _Current.Response.Cookies(_cookieName)
022.            aCookie.Values.Add(subKey, subValue)
023.        Else
024.            Dim aCookie As New HttpCookie(_cookieName)
025.            aCookie.Values.Add(subKey, subValue)
026.            _Current.Response.AppendCookie(aCookie)
027.        End If
028.    End Sub
029. 
030.    Public Function GetValue(ByVal subKey As String) As String
031.        Dim retValue As String = String.Empty
032.        If _Current.Response.Cookies(_cookieName) IsNot Nothing Then
033.            Dim aCookie As HttpCookie = _Current.Response.Cookies(_cookieName)
034.            Try
035.                retValue = aCookie.Values(subKey)
036.            Catch ex As Exception
037.                'Throw ex
038.            End Try
039.        End If
040.        Return retValue
041.    End Function
042. 
043.    ''' <summary>
044.    ''' Modify subKey and subValue
045.    ''' </summary>
046.    ''' <param name="subKey"></param>
047.    ''' <param name="subValue"></param>
048.    ''' <returns>True/False</returns>
049.    ''' <remarks>If subKey not exists recrete new</remarks>
050.    Public Function ModifyValue(ByVal subKey As String, ByVal subValue As String) As Boolean
051.        Dim suc As Boolean = False
052.        If _Current.Request.Cookies(_cookieName) IsNot Nothing Then
053.            Try
054.                _Current.Request.Cookies(_cookieName)(subKey) = subValue
055.                suc = True
056.            Catch ex As Exception
057.                Try
058.                    InsertValue(subKey, subValue)
059.                    suc = True
060.                Catch ex1 As Exception
061.                    Throw ex1
062.                End Try
063.            End Try
064.        End If
065.        Return suc
066.    End Function
067. 
068.    Public Sub Save()
069.        ' Setting a cookie's value and/or subvalue using the HttpCookie class
070.        Dim cookie As HttpCookie
071.        If _Current.Request.Cookies(_cookieName) IsNot Nothing Then
072.            _Current.Request.Cookies.Remove(_cookieName)
073.        End If
074.        cookie = New HttpCookie(_cookieName)
075.        If _data.Count > 0 Then
076.            Dim cookieData As IEnumerator = _data.GetEnumerator()
077.            Dim item As DictionaryEntry
078.            While cookieData.MoveNext()
079.                item = CType(cookieData.Current, DictionaryEntry)
080.                cookie.Values.Add(item.Key.ToString(), item.Value.ToString())
081.            End While
082.        End If
083.        _Current.Response.AppendCookie(cookie)
084.    End Sub
085. 
086. 
087.    Public Sub Delete()
088.        ' Set the value of the cookie to null and set its expiration to some time in the past
089.        If _Current.Response.Cookies(_cookieName) IsNot Nothing Then
090.            _Current.Response.Cookies(_cookieName).Value = Nothing
091.            ' last month
092.            _Current.Response.Cookies(_cookieName).Expires = System.DateTime.Now.AddMonths(-1)
093.        End If
094.    End Sub
095. 
096.    Public Sub Delete(ByVal subKey As String)
097.        ' Set the value of the cookie to null and set its expiration to some time in the past
098.        If _Current.Response.Cookies(_cookieName) IsNot Nothing Then
099.            Dim aCookie As HttpCookie = _Current.Request.Cookies(_cookieName)
100.            aCookie.Values.Remove(subKey)
101.            aCookie.Expires = DateTime.Now.AddDays(-1)
102.            _Current.Response.Cookies.Add(aCookie)
103.        End If
104.    End Sub
105. 
106.    ''' <summary>
107.    ''' Reading Cookie Collections
108.    ''' </summary>
109.    ''' <remarks></remarks>
110.    Public Function ReadingCookieCollections() As String
111.        Dim output As System.Text.StringBuilder = New System.Text.StringBuilder()
112.        Dim aCookie As HttpCookie
113.        Dim subkeyName, subkeyValue As String
114. 
115.        For i As Integer = 0 To _Current.Request.Cookies.Count - 1
116.            aCookie = _Current.Request.Cookies(i)
117.            output.Append("Name = " & aCookie.Name & "<br />")
118.            If aCookie.HasKeys Then
119.                Dim CookieValues As System.Collections.Specialized.NameValueCollection = aCookie.Values
120.                Dim CookieValueNames() As String = CookieValues.AllKeys
121.                For j As Integer = 0 To CookieValues.Count - 1
122.                    subkeyName = _Current.Server.HtmlEncode(CookieValueNames(j))
123.                    subkeyValue = _Current.Server.HtmlEncode(CookieValues(j))
124.                    output.Append("Subkey name = " & subkeyName & "<br />")
125.                    output.Append("Subkey value = " & subkeyValue & "<br /><br />")
126.                Next
127.            Else
128.                output.Append("Value = " & _Current.Server.HtmlEncode(aCookie.Value) & "<br /><br />")
129.            End If
130.        Next
131.        Return output.ToString()
132.    End Function
133. 
134.End Class



ปล. ยัดเงินใส่กระเป๋าให้หนึ่งกำมือ คงไม่ต้องบอกว่าจะใช้เงินอย่างไร?น่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 09:22:26 By : หน้าฮี
 

 

No. 3

Guest


จาก #No 2 ลืมบอกไปว่า "สูงสุดคืนสู่สามัญ"
หมายควยว่า "ใช้ HTML ธรรมดาฯ" นี่แหละในการสร้างสรรค์ผลงาน

Code (XML)
01.<select>
02.  <option value="หน้า">1</option>
03.  <option value="ฮี">2</option>
04.  <option value="หอย">3</option>
05.  <option value="งาม">4</option>
06.</select>
07. 
08.พ่อเอ็งชื่อ: <input type="text" name="faName" id="faName">
09.แม่เอ็งชื่อ: <input type="text" name="MaName" id="MaName">
10....
11....
12....

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 09:40:00 By : หน้าฮี
 

 

No. 4

Guest


จาก #NO 3 สาระสำคัญของ เวป ก็คือ Server/Client

พยายามจะบอกว่า อะไรที่ทำที่เครื่อง Client ได้ก็ต้องทำ (แน่นอนว่า มีได้/มีเสีย)
--- แต่ข้อดีมีมากกว่า อทิเช่น ความเร็วปรุ๊ดปร๊าดฯ ตอบสนองทันทีทันใด
--- ข้อเสียมันก็พอฯกับปิดไฟจับหอยเมีย (...)


โค๊ดข้างล่างนี้คือโค๊ดที่ผมหัดเขียน JavaScript/Jquery
--- รู้อะไรก็ให้มันรู้จริง

Code (JavaScript)
001.function divSetActiveView(divChild, vwID) {
002.    for (var i = 0; i < divChild.length; i++) {
003.        if (divChild[i].id == vwID) {
004.            divChild[i].style.display = "block";
005.        } else {
006.            divChild[i].style.display = "none";
007.        }
008.        //}
009.    }
010.}
011. 
012.//ใช้แทน GridView Server Control
013. 
014.function InitialDataTable(tableName) {
015.    var this_selected = [];
016.    $(function () {
017.        var objTable = $('#' + tableName).DataTable({
018.            responsive: true,
019.            lengthChange: false, //Page Size
020.            searching: true, //Search Box               
021.            bProcessing: true, //Progress
022.            bFilter: false,
023.            pagingType: "full_numbers",
024.            autoWidth: true,
025.            bServerSide: true,
026.            sAjaxSource: 'หน้าฮี WCF',
027.            sServerMethod: 'post',
028.            stateSave: false,
029.            "columnDefs": [
030.                {
031.                    "targets": [5],
032.                    "searchable": false,
033.                    "sortable": false,
034.                    "className": "dtCell_center",
035.                    "render": function (data, type, row) {
036.                        return '<input type="checkbox" class="checkboxes" value="' + data + '" />';
037.                    }
038.                }
039.            ],
040.            "fnInitComplete": function (oSettings, json) {
041.                $('.dataTables_filter').hide();
042.            },
043.            "rowCallback": function (row, data) {
044.                if ($.inArray(data[5], this_selected) !== -1) {
045.                    //var rowNumber = objTable.rows({ order: 'applied' }).nodes().indexOf($(row));
046.                    $(row).addClass('selected');
047.                }
048.            },
049.            "fnCreatedRow": function (nRow, aData, iDataIndex) { // Create tr id='XXX'
050.                $(nRow).attr('id', aData[5]);
051.            },
052.            "fnDrawCallback": function () {
053.                if (this.fnSettings() !== null) {
054.                    if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
055.                        $('.dataTables_paginate').css("display", "block");                 
056.                    } else {
057.                        $('.dataTables_paginate').css("display", "none");
058.                    }
059.                }
060.            }
061.        });
062. 
063.        function search(force) {
064.            var objSearch = $('#_txtSearch');
065.            var strSearch = $('#_txtSearch').val();
066.            if (!force && strSearch.length < 2) return; //wasn't enter, not > 1 char
067.            objTable.search(strSearch).draw();
068.            //More detail TestLargeRows.aspx
069.            //ทดสอบดึงข้อมูล 1 ล้านระเบียนผ่านเวป
070.        }
071.        $(document).on('keyup', '#txtSearchXXX', function (event) {
072.            clearTimeout($.data(this, 'timer'));
073.            if (event.keyCode == 13 || event.which == 13) { //e.which = Browser FireFox
074.                search(true);
075.            } else {
076.                $(this).data('timer', setTimeout(search, 3000)); //1000 ms x s วินาที
077.            }
078.        });
079.        $(document).on('click', '#_ButtonSearchStd', function (event) {
080.            var objSearch = $('#_txtSearch');
081.            var strSearch = objSearch.val();
082.            objTable.search(strSearch).draw();
083.            //objTable.draw();
084.        });
085. 
086.        $("#" + tableName + " thead tr th").resizable({
087.            handles: 'e'
088.        });
089. 
090.        $(document).on("dblclick", "#" + tableName + " tbody tr", function () {
091.            //ลบแถว
092.            //objTable.row('.selected').remove().draw(false);
093.            //var rowData = objTable.row(this).data(); //น่าสนใจ
094.            var ref = $(this).find('td:eq(0)').text(); //$(this).find('td:first').text();
095.            if (ref) {
096.                showMessageBox(ref);
097.            }
098.        });
099. 
100.        // Retain selection on reload (Multiple Selected/Single Selected)
101.        $('#' + tableName + ' tbody').on('click', 'tr', function () {
102.            this_selected.length = 0; //Clear Array
103.            objTable.$('tr.selected').removeClass('selected');
104.            this_selected.push(this.id); //Add a new item to an array (Append mode)
105.            $(this).toggleClass('selected');
106.        });
107.    });
108.}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 10:09:49 By : หน้าฮี
 

 

No. 5

Guest


ใช้ปืนฆ่าคนได้ย่อมใช้ดาบฆ่าคนได้เช่นเดียวกัน

อันนี้ทำไปเรื่อยฯ ไม่มีกำหนดเสร็จสมบูรณ์

Windows Calendar User Control (รองรับ Calture เช่น th-TH, en-US, en-GB)

xCalendar_01


อันนี้เขียนเล่นฯ ยังไม่ได้ข้อสรุป (วันนั้นเกิดเบื่อโลกขึ้นมา)

Code (VB.NET)
01.Private Function findDMY(ByVal txt As String, Optional ByVal dmy As String = "m") As String
02.    Dim strMonthRet As String = ""
03.    For i As Integer = 0 To txt.Length - 1
04.        If (_Mask(i).ToString()).ToLower() = dmy.ToLower() Then
05.            strMonthRet &= txt.Substring(i, 1)
06.        End If
07.    Next
08.    strMonthRet = If(strMonthRet = "", "0", strMonthRet) 'CInt(If(strMonthRet = "", "0", strMonthRet)) '.ToString("D2") 'Padding zero 01, 02, ..., 12
09.    Return strMonthRet '1-31, 01-31, 1-12,  01-12
10.End Function
11.Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
12.    If AscW(e.KeyChar) = Keys.Back OrElse AscW(e.KeyChar) = Keys.Delete OrElse AscW(e.KeyChar) = Keys.Left OrElse AscW(e.KeyChar) = Keys.Right Then
13.        e.Handled = False
14.        Return
15.    End If
16.    If Mask <> "" Then
17.        e.Handled = True
18.        Dim newText As String = Me.Text
19.        Dim Finished As Boolean = False
20.        Dim lstMaxDays As String() = {"31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31"}
21.        For i As Integer = Me.SelectionStart To _Mask.Length - 1
22.            Select Case (_Mask(i).ToString()).ToLower()
23.                Case "d"
24.                    If (Char.IsDigit(e.KeyChar)) Then
25.                        newText &= e.KeyChar.ToString()
26.                        Dim getDay As String = findDMY(newText, "d")
27.                        If (getDay.Length = 0 AndAlso e.KeyChar > "3") OrElse (getDay.Length = 2 AndAlso newText = "3" AndAlso e.KeyChar > "1") Then
28.                            Return
29.                        ElseIf CInt(getDay) > 31 OrElse getDay = "00" Then
30.                            Return
31.                        End If
32.                        'If CInt(getDay) > 31 OrElse getDay = "00" Then
33.                        '    Return
34.                        'End If
35.                        Finished = True
36.                    Else
37.                        Return
38.                    End If
39.                Case "m"
40.                    If (Char.IsDigit(e.KeyChar)) Then
41.                        newText &= e.KeyChar.ToString()
42.                        Dim getMonth As String = findDMY(newText, "m")
43.                        If CInt(getMonth) > 12 OrElse getMonth = "00" Then
44.                            Return
45.                        End If
46.                        Finished = True
47.                    Else
48.                        Return
49.                    End If
50.                Case "y"
51.                    If (Char.IsDigit(e.KeyChar)) Then
52.                        newText &= e.KeyChar.ToString()
53.                        Finished = True
54.                    Else
55.                        Return
56.                    End If
57.                Case Else 'Mask symbol.
58.                    newText &= _Mask(i)
59.            End Select
60.            If Finished Then
61.                Exit For
62.            End If
63.        Next
64.        'Update the Text.
65.        Me.Text = newText
66.        Me.SelectionStart = Me.Text.Length
67.    End If
68.End Sub


ปล. คิดได้หมดร้อยแปดพันเก้าแต่ไม่มีเวลาทำ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 10:25:52 By : หน้าฮี
 

 

No. 6



โพสกระทู้ ( 37 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 13:18:10 By : kornraphat
 

 

No. 7

Guest


อยากทำต่อให้สมบูรณ์แต่ไม่มีเวลา (ขี้เกียจแล้วว่ะเฮ้ย)

Code (VB.NET)
001.Imports System.Drawing
002.Imports System.Windows.Forms
003.'
004.<ToolboxBitmap(GetType(TextBox))> _
005.Public Class usrCtrlMaskTextBox : Inherits TextBox
006. 
007.#Region "  Private Variables "
008.    Private WithEvents _DTP As New DateTimePicker 'เอาไว้กันเหนียว (เรื่องอะไรตูจะไปคำนวณด้วยตัวเอง +55555)
009.    Private _Mask As String 'กำหนดได้ตามใจชอบเช่น "ไก่งามเพราะขนคนงามเพราะหอย"
010.    Private _Button As New Button() With {.Text = String.Empty} 'ปุ่มแสดงวันที่ให้เลือก
011.#End Region
012. 
013.#Region "    Properties "
014.    <System.ComponentModel.DefaultValue(GetType(String), "Text"), System.ComponentModel.Category("Appearance")> _
015.    Public Property Mask() As String
016.        Get
017.            Return _Mask 'เช่น หำMM/dd/yyyy, yyyy/หำdd/MM, etc... รองรับทุกรูปแบบ
018.        End Get
019.        Set(ByVal value As String)
020.            _Mask = value
021.        End Set
022.    End Property
023. 
024.    Private mKey As String
025.    <System.ComponentModel.DefaultValue(GetType(String), "Text"), System.ComponentModel.Category("Appearance")> _
026.    Public Property _Key() As String
027.        Get
028.            Return mKey
029.        End Get
030.        Set(ByVal value As String)
031.            mKey = value
032.        End Set
033.    End Property
034. 
035.#End Region
036. 
037.#Region "    Constructor "
038. 
039.    Public Sub New()
040.        AddHandler _Button.Click, Sub(หอย, งาม)
041.                                      '
042.                                      'Display Date Dialog.
043.                                      '
044.                                  End Sub
045.    End Sub
046. 
047.#End Region
048. 
049.    Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
050.        'MyBase.OnKeyDown(e)
051.        'e.Handled = True
052.    End Sub
053. 
054.    Private Function findDMY(ByVal txt As String, Optional ByVal dmy As String = "m") As String
055.        Dim strRet As String = ""
056.        For i As Integer = 0 To txt.Length - 1
057.            If (_Mask(i).ToString()).ToLower() = dmy.ToLower() Then
058.                strRet &= txt.Substring(i, 1)
059.            End If
060.        Next
061.        Return If(strRet = "", "0", strRet)
062.    End Function
063. 
064.    ''' <summary>
065.    ''' ตรวจสอบเดือนกุมภาพันธ์มี 29 วันหรือไม่?
066.    ''' Dim isLeap As Boolean = isLeapyear(2000)
067.    ''' </summary>
068.    ''' <param name="shrYear"></param>
069.    ''' <returns></returns>
070.    ''' <remarks></remarks>
071.    Private Function isLeapyear(ByVal shrYear As Short) As Boolean
072.        Return Date.IsLeapYear(shrYear)
073.    End Function
074. 
075.    Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
076.        If AscW(e.KeyChar) = Keys.Back OrElse AscW(e.KeyChar) = Keys.Delete OrElse AscW(e.KeyChar) = Keys.Left OrElse AscW(e.KeyChar) = Keys.Right Then
077.            e.Handled = False
078.            Return
079.        End If
080.        If Mask <> String.Empty Then
081.            e.Handled = True
082.            Dim newText As String = Me.Text
083.            Dim Finished As Boolean = False
084.            Dim daysInMonth = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
085.            Dim mask1 As String = String.Empty
086.            For i As Integer = Me.SelectionStart To _Mask.Length - 1
087.                mask1 = _Mask(i).ToString().ToLower()
088.                If Not (Char.IsDigit(e.KeyChar)) Then
089.                    Return
090.                Else
091.                    If "dmy".Contains(mask1) Then
092.                        newText &= e.KeyChar.ToString()
093.                        Finished = True
094.                    Else 'Mark symbol
095.                        newText &= mask1
096.                        Finished = False
097.                    End If
098.                End If
099.                Select Case mask1
100.                    Case "d"
101.                        Dim getDay As String = findDMY(newText, "d")
102.                        'ป้องกันการป้อนวันที่ >= 31 และ 00
103.                        If (CByte(getDay) > 31) OrElse (getDay.Length = 1 AndAlso e.KeyChar > "3") OrElse (getDay.Length > 1 AndAlso getDay.Substring(0, 2) = "00") Then
104.                            Return
105.                        End If
106.                    Case "m"
107.                        Dim getDay As String = findDMY(newText, "d")
108.                        Dim getMonth As String = findDMY(newText, "m")
109.                        'ป้องกันการป้อนเดือน > 12 และป้อนเดือน 00
110.                        If CByte(getMonth) > 12 OrElse (getMonth.Length > 1 AndAlso getMonth.Substring(0, 2) = "00") Then
111.                            Return
112.                        End If
113.                        'ป้อนเดือน 01 - 09 หรือ 1 - 9
114.                        If CByte(getMonth) > 0 Then
115.                            Dim lastDayOfMonth As Byte = daysInMonth(getMonth - 1)
116.                            If CByte(getDay) > lastDayOfMonth Then
117.                                Return
118.                            End If
119.                            If getMonth.Length = 1 AndAlso CByte(getMonth) <> 1 Then
120.                                getMonth = "0" & getMonth
121.                                'ตั้งใจทำ พิมพ์ 2 --> 02, 3 --> 03, 9 -->09 เป็นต้น แต่ขี้เกียจทำแล้ว
122.                            End If
123.                        ElseIf getMonth.Length > 1 AndAlso getMonth.Substring(0, 2) = "00" Then
124.                            Return
125.                        End If
126.                    Case "y"
127.                        Dim getDay As String = findDMY(newText, "d")
128.                        Dim getMonth As String = findDMY(newText, "m")
129.                        Dim getYear As String = findDMY(newText, "y")
130.                        If Not isLeapyear(CShort(getYear)) Then
131.                            daysInMonth(1) = 28 'เดือนกุมภาพันธ์มี่ 28 วัน
132.                        End If
133. 
134.                        '
135.                        'ตรวสอบปีที่ป้อน เดือนกุมพาพันธ์มี 29 วันหรือไม่?
136.                        'ขี้เกียจทำแล้วว่ะเฮ้ย
137.                        '
138.                End Select
139.                If Finished Then
140.                    Exit For
141.                End If
142.            Next
143.            'Update the Text.
144.            Me.Text = newText
145.            Me.SelectionStart = Me.Text.Length
146.        End If
147.    End Sub
148. 
149.    Protected Overrides Sub OnValidating(ByVal e As System.ComponentModel.CancelEventArgs)
150.        'ยังไม่ได้ทำและขี้เกียจทำ
151.    End Sub
152. 
153.    Public Sub ResetValue()
154.        MyBase.Text = String.Empty
155.    End Sub
156. 
157.    Protected Overrides Sub OnCausesValidationChanged(e As EventArgs)
158.        MyBase.OnCausesValidationChanged(e)
159.    End Sub
160. 
161.End Class

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 15:30:22 By : หน้าฮี
 

 

No. 8

Guest


จาก #NO7 บรรทัดที่ 57 ต้องตรวจสอบเพิ่มเติมดังนี้

Code (VB.NET)
1.If Array.IndexOf(_Mask, i) <> -1 Then
2.  If (_Mask(i).ToString()).ToLower() = dmy.ToLower() Then
3.      strRet &= txt.Substring(i, 1)
4.  End If
5.End If



ปล. ความเป็นศิลปินโปรแกรมเมอร์มันแตกต่างกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-11-25 15:49:08 By : หน้าฮี
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเกี่ยวกับการเก็บ dropdown value ใน cookies ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่