how to at retrive a image at server side and display on client side? any thing wrong? my picture is store at project. anyone have any idea to help me thx. i'm try alot solution but it still cant work
<asp:Image ID="rating" runat="server" />
rating.Attributes.Add("style", "background-image:url('Image/Icon/Rank/rating1.gif')");
You can use src attribute of image tag.
rating.Attributes.Add("src", "Image/Icon/Rank/rating1.gif");
Related
I want to show an image on my website from a folder which is outside the asp.net application on my desktop. I have tried this but it is not uploading the image.
<asp:Image ID="Image2" runat="server" ImageUrl="C:\Users\MyName\Desktop\Images\0.jpg" />
Is there any other way to give the path. What is wrong I am doing. Please advise. Thanks in advance.
I am trying to encode the url using HttpUtility.UrlEncode,
but not able to make it work. HyperLink control is in the
template field of gridview.
Can anyone please help me out with this?
I have tried changing the target application and by adding
System.Web reference to project but still not able to Encode
the url.
Please guide me.
Following is part of my code:-
<asp:HyperLink ID="lnkDetailsPage" runat="server" NavigateUrl='<%# string.Format("~/YellowPages/YellowDetailView.aspx?CustomerId={0}",HttpUtility.UrlEncode(Eval("CustomerId").ToString())) %>'></asp:HyperLink>
Thanks in advance.
Use Server.UrlEncode() instead. Why do you need to encode your CustomerID?!
I was thinking to do this server side, but what i was wanting to do was disable the telerik control called the "Editor." Located at the site: telerick editor control.
My reasoning behind this was that I wanted to give a user the exact look and feel of the object while having everything disabled. I didnt want to use an image at all because it would be stretched, shrank, clicked, etc and wanted to maintain how the editor would look. I had an alternate option i COULD do but not only it would be ineffecient, but have holes to open up for injection.
Looking through the API for that i didnt see which way to accomplish that.
I was thinking to do jquery maybe on the client side to disable, but why do that when you can set the item itself be flagged as disabled and never be entirely sent to the client.
Thoughts? Ideas? How would you go about it? I didnt see methods or attributes that really led to what i was doing.
You can just set enabled="false" on the radEditor declaration in your aspx page:
http://www.telerik.com/help/aspnet-ajax/editor-disabling-radeditor.html
<telerik:RadEditor runat="server" ID="RadEditor1" Enabled="false">
<Content>
<strong>sample content</strong>
</Content>
</telerik:RadEditor>
On the Server Side you can do
RadEditor1.Enabled = false;
In jquery,
try
$("#RadEditor1").prop('disabled', true);
In sql server database, I have column name Image which has urls like http://www.xyz.com/1009/image1.jpg
Now I want to display it on my datalist. But it is not showing any image. It is might be the case because it is expecting the Image URL to be ~/Folder/abc.jpg
Then how to show the image on the asp.net page when I have image URL, which control I need to use and how?
Do you see little red X instead of an image?
If so, right click it --> Properties (IE) to see the URL it's referring to.
Might give us hint on what's going on. :)
If you are getting the image from the database in for the form xzy.com/1009/image1.jpg but want to add the http:// then your code should be
<asp:Image ID="imgmain" runat="server" ImageUrl='<%#String.Format("http://{0}", Eval("Image"))%>' Width="80" Height="80" />
Server controls like Image.ImageUrl make this very easy, but trying to achieve the same thing in code behind to an IMG html control is not that straightforward.
For example using an Asp:Image server control and setting ImageUrl property to "~/Images/Test.jpg" works fine no matter what directory i place the code in. (asp.net transforms tilde directory to relative)
How can i do the same in code behind? when i am trying to create an HTML IMG control?
Use Page.ResolveUrl("~/.....");
In the template:
<img id="imgTest" runat="server" />
In the codebehind:
imgTest.Attributes["src"] = this.ResolveUrl("~/yourimage.gif");
Does this solve your problem? Not really sure why you're not using an asp:image control...