 |
|
อยากสอบถามเรื่อง ajax extension น่ะครับ ว่าเหมือนหรือต่างกับ ajax ที่ใช้ submit form ครับ |
|
 |
|
|
 |
 |
|
เข้าใจก่อนน่ะครับว่า Ajax มันเป็นเทคนิคการเขียนโปรแกรมโดยไม่ต้อง Refresh ทั้ง Page ซึ่งปกติแล้ว PHP เราจะต้องเขียนเอง อาจจะใช้พวก jQuery เข้ามาช่วย แต่บน .NET Framework (บน Windows Server/Hosting) มันมี Tools ที่ชื่อว่า Ajax Extension ไว้เขียนบน ASP.Net ช่วยในการเขียน Ajax ได้ง่ายขั้นครับ แต่รูปแบบการทำงานก็ไม่ต่างกันครับ
|
 |
 |
 |
 |
Date :
2015-08-05 17:59:40 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น้อยคนนักที่จะก้าวมาถึงจุดนี้ได้ (อ่าน SourceCode และเข้าใจอย่างถ่องแท้)
Code (VB.NET)
Imports System.Collections.Generic
Imports System.Linq
Imports System.Reflection
Imports System.Linq.Expressions
Public Module IEnumerableHelper
Sub New() 'Public
End Sub
Private orderBy_ As MethodInfo = GetType(Enumerable).GetMethods(BindingFlags.[Static] Or BindingFlags.[Public]) _
.Where(Function(x) x.Name = "OrderBy" AndAlso x.GetParameters().Length = 2).First()
<System.Runtime.CompilerServices.Extension()> _
Public Function OrderBy(Of TSource)(source As IEnumerable(Of TSource), propertyName As String) As IEnumerable(Of TSource)
Dim pi = GetType(TSource).GetProperty(propertyName, BindingFlags.[Public] Or BindingFlags.FlattenHierarchy Or BindingFlags.Instance)
Dim selectorParam = Expression.Parameter(GetType(TSource), "keySelector")
Dim sourceParam = Expression.Parameter(GetType(IEnumerable(Of TSource)), "source")
Return Expression.Lambda(Of Func(Of IEnumerable(Of TSource),
IOrderedEnumerable(Of TSource)))(Expression.[Call](orderBy_.MakeGenericMethod(GetType(TSource), pi.PropertyType),
sourceParam, Expression.Lambda(GetType(Func(Of ,)).MakeGenericType(GetType(TSource), pi.PropertyType),
Expression.[Property](selectorParam, pi), selectorParam)), sourceParam).Compile()(source)
End Function
<System.Runtime.CompilerServices.Extension()> _
Public Function OrderBy(Of TSource)(source As IEnumerable(Of TSource), propertyName As String, ascending As Boolean) As IEnumerable(Of TSource)
Return If(ascending, source.OrderBy(propertyName), source.OrderBy(propertyName).Reverse())
End Function
End Module
|
 |
 |
 |
 |
Date :
2015-08-05 21:54:58 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|