c# - Setting imageURL using a function in ASP.NET -


I did this work within the repeaters and it worked. Although I can not get down to work for me in the normal webform page, the images appear as broken links and breakpoints which I have put in codebehind.

(in the aspx file)

  & lt; Asp: ImageButton id = "ImageButton1" runat = "server" image URL = '& lt;% # GetImage Directory ()% & gt; BTNRunRort Page '/ & gt;  

(codebehind)

  public string GetImage directory () {return "~ / App_Variants / LBSX / images /"; }  

This is the second method I have tried, in the second, I tried to pass the name of the imagination as a string, and it would return the whole link in the same way Will return No luck!

Any thoughts?

Thank you!

[edit] Help Thanks to everyone at the end of the easy signals I found a recursive snippet that made this kind of move:

  Private Zero UpdateImages (Control Guardian) {foreach (parent.Controls in Control C) {ImageButton i = C Image button; If (i! = Null) {i.imageUrl = "~ / App_Variants / LBSX / images /" + i.ImageUrl; } If (c.HasControls ()) {UpdateImages (c); }}} Secure Zero Page_load (Object Sender, EventEurges E) {Update Images (Page);    

"text">

First of all, such as Zachary Has been mentioned, you are using the code block for data binding.

Second, as you've already tried using an inline expression ( ;% =%> ), either in your case or not Because you can not use an inline expression for any property of a server-tag

You can define an image button instead using HTML syntax, Runat = "server" tag, and inline to get your image URL Could use these expressions:

  & lt; Input type = "image" src = "& lt;% = GetImage directory ()% & gt; BTNRRport." Name = "image" />  

What is an inline expression, this answer & lt;% =%> calls the answer with the value between . As a parameter, such as & lt;% = this.MyVar% & gt; is feedback. Write (this.MyVar) .


Comments