Private Sub Repeater2_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater2.ItemCommand
If e.CommandName = "btn_delgallery" Then
Dim CustomerID As String = Convert.ToString(e.CommandArgument)
Label1.Text &= CustomerID
End If
End Sub
'ใส่ sub นี้ลงไปใน code-behind เดี๋ยว compiler มันจะเชื่อม event นี้ให้เอง
Sub ButtonOnRepeaterDelete_Click(sender As Object, e As EventArgs)
dim button as Button = DirectCast(sender ,Button)
dim dir_gallery as string = button.CommandArgument
'............................
'.........code อะไรก็ว่าไป
End Sub
Protected Sub UploadThisFile(ByVal upload As FileUpload)
Dim rndnumber As Random
Dim number As Integer
rndnumber = New Random
number = rndnumber.Next(1, 80000)
Dim filename As String = number.ToString & "_" & upload.FileName
If FileUpload1.HasFile Then
Dim img As String = String.Empty
Dim bmpImg As Bitmap = Nothing
Try
bmpImg = Resize_Image(FileUpload1.PostedFile.InputStream, 960, 960)
bmpImg.ToString()
'Server.MapPath("~/Uploads")
img = Server.MapPath("~/Uploads/") + number.ToString + ".png"
ins_album(abname:=number.ToString + ".png", dir_name:=number.ToString)
bmpImg.Save(img, ImageFormat.Jpeg)
Catch ex As Exception
Response.Write("Error occured: " & ex.Message.ToString())
Finally
img = String.Empty
bmpImg.Dispose()
End Try
End If
End Sub
Code (VB.NET)
Private Function Resize_Image(ByVal streamImage As Stream, ByVal maxWidth As Integer, ByVal maxHeight As Integer) As Bitmap
Dim originalImage As New Bitmap(streamImage)
Dim newWidth As Integer = originalImage.Width
Dim newHeight As Integer = originalImage.Height
Dim aspectRatio As Double = CDbl(originalImage.Width) / CDbl(originalImage.Height)
If aspectRatio <= 1 AndAlso originalImage.Width > maxWidth Then
newWidth = maxWidth
newHeight = CInt(Math.Round(newWidth / aspectRatio))
ElseIf aspectRatio > 1 AndAlso originalImage.Height > maxHeight Then
newHeight = maxHeight
newWidth = CInt(Math.Round(newHeight * aspectRatio))
End If
Return New Bitmap(originalImage, newWidth, newHeight)
End Function
Date :
2015-02-24 10:26:01
By :
mooer
No. 6
Guest
หากจะเขียนไฟใดไลงในโฟดเดอร์ของแอบ asp.net มันต้องเพิ่ม permission ลงด้วยนะครัช
ในกรณีที่ยังพัฒนาด้วย Visual studio (ห้องภาพเสมือนจริง ตึ่งโป๊ะ) แต่ถ้าเอาไปติดตั้งใน server
ใน app pool ของ iis มันก็ต้องจัดการด้วย iis นะครัช