Is is possible to have different image (for the same image button) in different pages in asp.net website. Say an image button is displayed in different or more than one page. I want to have differen image for the image button every time the page is requested
or the page is refreshed. Is this possible?
Are there any websites that provide images for free? Most of them I have visited have some or other strings attached. Any that provide free images?
Yes it is. Just set the image url on the page load for each page. That way when the page is hit the new image url will be served back to the image you want for that page. If you need help with the code let me know.
Yes, it's quite possible. And there's several different ways to implement that.
You may dinamically alter the image buttons' ImageUrl property at each load, although i'd say this would be a bit cumbersome if you have several ImageButtons present.
In that case, i'd recommend to use the CssClass property, and specify the images to be loaded directly on the CSS file, the use
Compound Classes to change the whole block dinamically.
Thats assigning image url. How would u assign a new image when page refreshes?
That's the closest he can go without writing the whole solution for you, and that would be counterproductive. =) You described the situation yourself.
When page refreshes, assign new image: At Page_Load event, set a different string to the property.
If you don't want to set the same string again, check the property content before you overwrite it. Or perhaps use the Session object to hold the current value.
Marked as answer by Chen Yu - MSFT on Jan 02, 2013 06:37 AM
N1ZAM
Member
84 Points
81 Posts
New image in every page! Is that possible???
Dec 26, 2012 12:53 PM|LINK
Hey guys!
Is is possible to have different image (for the same image button) in different pages in asp.net website. Say an image button is displayed in different or more than one page. I want to have differen image for the image button every time the page is requested or the page is refreshed. Is this possible?
Are there any websites that provide images for free? Most of them I have visited have some or other strings attached. Any that provide free images?
Thanks,
N1ZAM
stockcer
Member
498 Points
128 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 12:56 PM|LINK
Yes it is. Just set the image url on the page load for each page. That way when the page is hit the new image url will be served back to the image you want for that page. If you need help with the code let me know.
ASP.NET Arvixe Liaison
James River Webs, Inc.
OnoSendai
Participant
1144 Points
239 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 01:03 PM|LINK
Yes, it's quite possible. And there's several different ways to implement that.
You may dinamically alter the image buttons' ImageUrl property at each load, although i'd say this would be a bit cumbersome if you have several ImageButtons present.
In that case, i'd recommend to use the CssClass property, and specify the images to be loaded directly on the CSS file, the use Compound Classes to change the whole block dinamically.
N1ZAM
Member
84 Points
81 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 01:20 PM|LINK
Yes please!
Please help me with the code.
Thanks,
N1ZAM
stockcer
Member
498 Points
128 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 01:41 PM|LINK
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
End
ASP.NET Arvixe Liaison
James River Webs, Inc.
N1ZAM
Member
84 Points
81 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 02:16 PM|LINK
Thats assigning image url. How would u assign a new image when page refreshes?
OnoSendai
Participant
1144 Points
239 Posts
Re: New image in every page! Is that possible???
Dec 26, 2012 02:46 PM|LINK
That's the closest he can go without writing the whole solution for you, and that would be counterproductive. =) You described the situation yourself.
When page refreshes, assign new image: At Page_Load event, set a different string to the property.
If you don't want to set the same string again, check the property content before you overwrite it. Or perhaps use the Session object to hold the current value.