473,803 Members | 3,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

1.1: Setting ImageUrl of ImageButton does not work

DC
Hi,

why does this not work:

<asp:ImageButto n
id="myButt"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<% =GetMyButtUrl() %>"
</asp:ImageButton >

( I get src="<% =GetMyButtUrl() %>" in the resulting HTML)

while this (in a DataGrid) works perfectly:

<ItemTemplate >
<asp:ImageButto n
id="myButtInAGr id"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<%# GetMyButtUrl() %>">
</asp:ImageButton >
</ItemTemplate>

Regards
DC

Jul 27 '07 #1
2 2892
The <%= ... %executed during rendering. But the object ImageButton is
created at the very beginning when Page is initialized.
That would explain why it does not work.

You simply can not attach to property of the ImageButton logic that is
executed during rendering. It has not run yet.

---------------------------
<%# GetMyButtUrl() %called binding. To tell you the truth I am not sure
how it works. But my guess the .NET parser simply puts the code ImageUrl =
GetMyButtUrl(); when converts aspx page to C#.

So in your example simply replace <%= with <%# and it might work.
I am saying might because i am not sure how exactly <%# %works and if any
additional things required from the object (in your case ImageButton) to
make it work.
George.


"DC" <dc@upsize.dewr ote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
Hi,

why does this not work:

<asp:ImageButto n
id="myButt"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<% =GetMyButtUrl() %>"
</asp:ImageButton >

( I get src="<% =GetMyButtUrl() %>" in the resulting HTML)

while this (in a DataGrid) works perfectly:

<ItemTemplate >
<asp:ImageButto n
id="myButtInAGr id"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<%# GetMyButtUrl() %>">
</asp:ImageButton >
</ItemTemplate>

Regards
DC

Jul 27 '07 #2
DC
On 27 Jul., 15:01, "George Ter-Saakov" <gt-...@cardone.com wrote:
The <%= ... %executed during rendering. But the object ImageButton is
created at the very beginning when Page is initialized.
That would explain why it does not work.

You simply can not attach to property of the ImageButton logic that is
executed during rendering. It has not run yet.

---------------------------
<%# GetMyButtUrl() %called binding. To tell you the truth I am not sure
how it works. But my guess the .NET parser simply puts the code ImageUrl =
GetMyButtUrl(); when converts aspx page to C#.

So in your example simply replace <%= with <%# and it might work.
I am saying might because i am not sure how exactly <%# %works and if any
additional things required from the object (in your case ImageButton) to
make it work.

George.

"DC" <d...@upsize.de wrote in message

news:11******** **************@ 22g2000hsm.goog legroups.com...
Hi,
why does this not work:
<asp:ImageButto n
id="myButt"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<% =GetMyButtUrl() %>"
</asp:ImageButton >
( I get src="<% =GetMyButtUrl() %>" in the resulting HTML)
while this (in a DataGrid) works perfectly:
<ItemTemplate >
<asp:ImageButto n
id="myButtInAGr id"
runat="server"
OnCommand="myBu tt_kick"
ImageUrl="<%# GetMyButtUrl() %>">
</asp:ImageButton >
</ItemTemplate>
Regards
DC- Zitierten Text ausblenden -

- Zitierten Text anzeigen -
Thank you, George. I tried using <%# ... %outside a template, but it
does not work.

Regards
DC

Jul 30 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2038
by: David Berman | last post by:
I'm having a problem with the ImageButton class. I want to set the ImageURL to an asp page, like: Thumbnail.ImageURL = "getpicturefromdatabase.aspx?INDEX=52&GALLERY=12"; The problem is, when the control renders, it renders the url incoded as "getpicturefromdatabase.aspx?INDEX=52&amp;GALLERY=12" so the other page doesn't process the request correctly. I checked in the debugger and the value for the property looks to be exactly what I want...
2
1693
by: Jeroen Klooster | last post by:
Hi all! I'm having some trouble using user controls. Situation: An apsx page contains an user control (Control A) that contains another user control(Control B). Control B is located in the subfolder "Controls" and has some imagebutton server controls. I want to set the imageurl of these image controls directly into the html using:
1
1815
by: John Espinosa | last post by:
I have a user control with an ImageButton. How can I change the ImageURL on that user control through the aspx page calling the user control??
2
2444
by: mich_stone | last post by:
Dear world, I have an IMAGE control placed on my .aspx page with its ImageUrl property not set. In my code, i am setting it equal to something using the following statement img.ImageUrl = Server.MapPath ("usedIcons/AssignAccess/" + reader.ToString ());
5
1715
by: Russell Smallwood | last post by:
Hello all, Why can't I wire up an event during the "Raise PostBackEvent" stage of a postback? Just in case this is the wrong question, the situation: deep in the bowls of some code-behind loop: ImageButton A is created (with ID "A"). ImageButton A's click event is
2
3730
by: dotnetjose | last post by:
Hi Folks, My subject message pretty musch explains it. By Default the Form definition sits at the Master Page file. Is there a way I can access the setting from my Content Page that uses a Master Page? Thanks in advance.
4
5655
by: AG | last post by:
I have a asp.net 2.0 gridview control with select, edit, delete buttons enabled and set to image button type to display my images. Is there any way to access the selectedimageurl property at run time so I can supply a different image for the selected row? I am assuming that I would do it in the RowDataBound event. Or do I need to use a separate template column? TIA --
3
2258
by: Ganesh | last post by:
Hi There I've assigned the Imageurl on ImageButton in design time like this http://localhost/aspnetsbs_cs/SimpleTest/WebForm4.aspx?image=images/one.jpg&size=100 but when i try from on run time, it does not seem to be working someone can advise me please
2
2263
by: Nathan Sokalski | last post by:
I have a resource file (*.resx) with several images in it. I am having trouble finding a way to use these images for controls such as Image, ImageButton, and other controls that an image can be assigned to. I have no trouble using String resources, but since the ImageUrl property expects a String, not an image, I am having trouple here. The only solution I can come up with is to create an extra Page that takes a querystring and returns an...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.