Monday, March 17, 2008

Create Thumbnail image

Protected Sub btnCreatThumb_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreatThumb.Click
Dim objImage, objThumbnail As System.Drawing.Image
Dim strServerPath, strFileName As String
Dim shtWidth, shtHeight As Short
'get image folder path on server
strServerPath = "C:\Documents and Settings\user2\Desktop\aajanachle1.jpg"
'retrive name of file to resize from query string
strFileName = "C:\Documents and Settings\user2\Desktop\aajanachle1.jpg"
'retrive file ,or error.gif if not available
Try
objImage = Drawing.Image.FromFile(strFileName)
Catch
objImage = Drawing.Image.FromFile(strServerPath)
End Try
'retrive width
shtWidth = 50
'work out a proportion height from widht
shtHeight = objImage.Height / (objImage.Width / shtWidth)
'Create Thumbnail
objThumbnail = objImage.GetThumbnailImage(shtWidth, shtHeight, Nothing, System.IntPtr.Zero)
'send down to client show image in browser
Response.ContentType = "image/Jpeg"
'objThumbnail.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
objThumbnail.Save("C:\Documents and Settings\user2\Desktop\" + "ddc.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'Tidy up
objImage.Dispose()
objThumbnail.Dispose()
End Sub

Wednesday, March 5, 2008

GridView Specific Row Color Through DataBase

-------------------------
Grid Pager Text Visible False
-------------------------
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
Dim topRow As GridViewRow = GridView1.TopPagerRow
Dim bottomRow As GridViewRow = GridView1.BottomPagerRow

If (GridView1.PageIndex) = 0 Then
CType(topRow.FindControl("lbPrevious"), LinkButton).Enabled = False
CType(topRow.FindControl("lbPrevious"), LinkButton).CssClass = "DisableLink"

CType(bottomRow.FindControl("lbPrevious"), LinkButton).Enabled = False
CType(bottomRow.FindControl("lbPrevious"), LinkButton).CssClass = "DisableLink"
End If

If (GridView1.PageIndex + 1) = GridView1.PageCount Then
CType(topRow.FindControl("lbNext"), LinkButton).Enabled = False
CType(topRow.FindControl("lbNext"), LinkButton).CssClass = "DisableLink"

CType(bottomRow.FindControl("lbNext"), LinkButton).Enabled = False
CType(bottomRow.FindControl("lbNext"), LinkButton).CssClass = "DisableLink"
End If
End Sub
---------------------------------------------------------------------------
Grid view Row Color specifice with database
----------------------------------------------------------------
Protected Sub gvSelectesdShop_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvSelectesdShop.RowDataBound
' 'If e.Row.RowType = DataControlRowType.DataRow Then
' ' Dim status As Boolean = CType(e.Row.FindControl("Status"), Label).Text
' ' If status = False Then
' ' e.Row.BackColor = Drawing.Color.AntiqueWhite
' ' e.Row.ToolTip = "This Shop is not approved yet!"
' ' End If
' 'End If
'End Sub