Seven price
asked on
image ImageUrl
Dim Image1 As New Image
Image1.ID = "Image1"
Image1.ImageUrl = "~\phonelist\Photos\camera .gif"
Image1.Visible = True
<asp:Image ID="Image1" Visible="True" runat="server" />
I trying to do this in VB but the src keep coming up blank. I could do this on the front end but I need to make this dynamic for other reason. But why nothing appears in the src, that is a mystery to me.
Image1.ID = "Image1"
Image1.ImageUrl = "~\phonelist\Photos\camera
Image1.Visible = True
<asp:Image ID="Image1" Visible="True" runat="server" />
I trying to do this in VB but the src keep coming up blank. I could do this on the front end but I need to make this dynamic for other reason. But why nothing appears in the src, that is a mystery to me.
<img id="ctl00_Attendance1_Repeater1_ctl00_Image1" src="" style="border-width:0px;" />
Are you adding the control to the page
below code works good for me
Image img = new Image();
img.ImageUrl = "file.jpg";
Page.Controls.Add(img);
below code works good for me
Image img = new Image();
img.ImageUrl = "file.jpg";
Page.Controls.Add(img);
ASKER
Object reference not set to an instance of an object.Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept ion: Object reference not set to an instance of an object.
Source Error:
Line 18: Line 19: Line 20: Me.Image1.ImageUrl = "~\phonelist\Photos\camera .gif" Line 21: Image1.Visible = True Line 22: Page.Controls.Add(Image1)
Exception Details: System.NullReferenceExcept
Source Error:
Line 18: Line 19: Line 20: Me.Image1.ImageUrl = "~\phonelist\Photos\camera
Me.Image1.ImageUrl = "~\phonelist\Photos\camera.gif"
ASKER
Its because it is in a repeater thats why. How can i get this to work inside the repeater
dim img as Image = Page.FindControl("image1") ' you may need to type cast the control to Image here
img.ImageUrl = "image.jpg";
img.ImageUrl = "image.jpg";
ASKER
Nope still Object reference not set to an instance of an object.Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
only when its in the repeater.
only when its in the repeater.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry nothing either if you create a repeater and test it you will see.
Dim img As Image = Page.FindControl("image1") ' you may need to type cast the control to Image here
img.ImageUrl = "~\phonelist\Photos\camera .gif"
Dim img As Image = Page.FindControl("image1")
img.ImageUrl = "~\phonelist\Photos\camera
Why are you declaring a new image in the code behind? (Dim Image1 as new Image)
You could just do Me.Image1.ImageUrl = "~\phonelist\Photos\camera
Now it seem like your image control is in a repeater so you might wanna watch out for how you handle that...