بسم الله الرحمن الرحيم
هناك مشكله معى فى اضافة div لاعرض بها صورة داخل الجريدفيو انا استخدم هذا الكود لتحجيم صورة واضافتها داخل الجريدفيو
هذا الخطأ يظهر
Object reference not set to an instance of an object
ملاحظة الخطأ يظهر لى فى اخر سطر
s.InnerHtml = "<img src=" + imageurl + " border='0' " + s_ImageSize + "/>"
الكود المستخدم
Public Function COMMONFUNCTIONS_IMAGES_RESIZE_TO_TAG(ByVal img As System.Drawing.Image, ByVal MaxWidth As Integer, ByVal MaxHeight As Integer) As String
If img.Width > MaxWidth Or img.Height > MaxHeight Then
Dim widthRatio As Double = Convert.ToDouble(img.Width / MaxWidth)
Dim heightRatio As Double = Convert.ToDouble(img.Height / MaxHeight)
Dim ratio As Double = Math.Max(widthRatio, heightRatio)
Dim newWidth As Integer = Convert.ToInt32(img.Width / ratio)
Dim newHeight As Integer = Convert.ToInt32(img.Height / ratio)
Return "< width=" + newWidth.ToString() + " height= " + newHeight.ToString() + " />"
Else
Return ""
End If
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim imageurl As String = "img_01.jpg"
Dim Img_Width As Integer = Convert.ToInt32(100)
Dim Img_Height As Integer = Convert.ToInt32(100)
Dim s_ImageSize As String = "<>"
If File.Exists(Server.MapPath(imageurl)) Then
s_ImageSize = COMMONFUNCTIONS_IMAGES_RESIZE_TO_TAG(System.Drawing.Image.FromFile(Server.MapPath(imageurl)), Img_Width, Img_Height)
End If
Dim s As New System.Web.UI.HtmlControls.HtmlGenericControl("div1")
s = GridView1.FindControl("div1")
s.InnerHtml = "<img src=" + imageurl + " border='0' " + s_ImageSize + "/>"
End Subبرجاء المساعده وجزاكم الله خيرا


