.aspx
<tr>
<th><asp:Label runat="server" ID="_imageName" Text="이미지"></asp:Label></th>
<td>
<asp:Image ID="_image" runat="server" Height="190px" Width="360px" />
</td>
</tr>
.aspx.cs
_image.ImageUrl = "D:\SVN\Project\ImageFiles\10238\imagetest2.jpg";
Image is not showing up.
Is it a path problem?
The image file is definitely in that folder.
try this :
_image.ImageUrl = "~/ImagesFiles/10238/imagetest2.jpg";
Or directly in your HTML :
<td>
<asp:Image ID="_image" runat="server" Height="190px" Width="360px" ImageUrl="~/ImagesFiles/10238/imagetest2.jpg" />
</td>
see documentation here
The client page isn't accessing the file. It's just setting the file's path to the HTML output for the client (web browser) to access it. Resulting in this:
<img src = "D:\SVN\Project\ImageFiles\10238\imagetest2.jpg" />
Since the user doesn't have access to that file(img) (because it is available for localhost, you must serve this file(img)), the img tag won't work.
Related
I have a listview which has a hyperlink in the item template, the hyperlink contains labels for my text(tried direct text to hyperlink also but got the same result).
The code is like below
<asp:ListView runat="server" ID="SampleListview" OnItemDataBound="Listview_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemplaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:HyperLink runat="server" ID="URL">
<asp:Label ID="Label" runat="server" />
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
On the item data bound I have added code for htmlEncode and decode so that the HTML tags don't render on the application.
Label.text = HttpUtility.HTMLDecode(HttpUtility.HtmlEncode(datarow.Value));
My problem is that this code works fine with and normal text, but when the text is #### #### my output shows only ####. Upon removing the hyperlinks my issue was fixed.
Thinking the issue is related to hyperlink I have created a fiddle
http://jsfiddle.net/uf9nbp8s/ but it works fine here and I have no clear explanation as to why the behaviour is the way I am seeing on application.
I dont know if the my question is good or bad or duplicate but I really want to ask you a favor.
My designer gave me grid design using html tables which looks quite handsome but when I use the same css classes in asp gridview it totally looks different.
Additional Info: In my project I have used Telerik grids. I have tried applying all the css at that too but of no use.
I cant change the designer css because its for all our company.
Now at last I want to use the same table as designer gave me and use it as grid but i really dont know how to fill it from datatable?
1. GridView generates/renders code in which it is difficult to impossible to modify.
2. I would stay away from Telerik as well.
3. Use Bootstrap CSS, you should be very happy with bootstrap css framework as you will get that look above very easily.
With Bootstrap you would use classes like class=table table-striped and you effectively have a nice grid with alternating row colors just like I see in the image that you posted.
With ASP.NET , use Nuget and install Bootstrap. Reference in Masterpage or layout.
I assume that you have styles that overwrite what your designer gave to you. Perhaps also if you are using THEIR stylesheets, make sure to overwrite the default styles. Either OMIT the style reference in master page etc... or place their stylesheet references below the default in say a asp.net web forms or mvc application. ( I assume web forms with masterpage since you are saying Gridview).
You can use ListView to include components. here is the example code for ListView.
<asp:ListView ID="ListView1" GroupPlaceholderID="group" GroupItemCount="1" ItemPlaceholderID="item" runat="server">
<LayoutTemplate>
<table>
<asp:PlaceHolder runat="server" ID="group"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="item"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<table cellpadding="2" cellspacing="0" border="1" style="width: 200px; height: 100px">
<tr>
<td>
<span>
<%# Eval("Id") %>
</span>
</td>
</tr>
<tr>
<td>
Name: <span><%# Eval("Field_name_of_your_DB") %></span><br />
Number: <span><%# Eval("Field_name_of_your_DB") %></span><br />
Date: <span><%# Eval("Field_name_of_your_DB", "{0:MM dd, yyyy}") %></span><br />
Comment: <span><%# Eval("Field_name_of_your_DB") %></span><br />
</td>
</tr>
</table>
</td>
</ItemTemplate>
</asp:ListView>
I tried to get image Path from database with using eval but in cs part I get different path name.
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:HiddenField ID="HiddenField1" Value='<%#Eval("Path")%>' runat="server" />
<img alt="image" style="text-align: center" src="<%#Eval("Path")%>" /></a><asp:CheckBox
ID="CheckBox1" runat="server" />
<br></br>
</ItemTemplate>
</asp:Repeater>
and in .cs part I tied to get this path value but it brings me very different datapath
foreach (RepeaterItem item in Repeater1.Items)
{
CheckBox ch = (CheckBox)item.FindControl("CheckBox1");
HiddenField hf = (HiddenField)item.FindControl("HiddenField1");
if (ch.Checked)
{
Image_BLLcs ibll = new Image_BLLcs();
File.Delete(hf.Value);
ibll.Delete(hf.Value);
}
how can I solve these problem, can you help me?
for example
in my database path is equal image/images (3).jpg
but when I execute this code it shows this C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\image\images (3).jpg as a path.
I have used Server.MapPath and it solved my problem
File.Delete(Server.MapPath(hf.Value));
ibll.Delete(Server.MapPath(hf.Value));
I have a page that dynamically generated a list of links to a web page (aspx) that opens an image. I do not have direct access to the PDF, only through the ASPX. The code behind is C#.
So if I have a page that has codes that looks like this
<table>
<tr>
<td>
<asp:Panel ID="pnlImageList" runat="server" Visible="true" HorizontalAlign="Center" >
<a href="http://someserver.com/EDocs/View.aspx?application=MB&seqnum=260">
View Scan # 1</a>
</asp:Panel>
</td>
<td>Open Image here</td>
</tr>
</table>
How do I open the view.aspx link in the cell labels 'Open Image Here'??
AHIA,
LarryR...
Use an embedded iframe as shown here:
http://pxd.me/dompdf/www/examples.php
This is essentially doing what you want -- clicking a link (click on any of the "HTML" or "PDF" links) brings up a file in the embedded iframe.
I know how you can set an tag's url attribute programmatically in c#, but it seems when I try to access the image element inside of a tag I cannot access it.
The is residing in the <AlternatingItemTemplate>.
NOTE: I am only having this issue inside the <AlternatingItemTemplate>
Now the ListView tag is also databound.(this is probably why I cannot access, because it isn't guaranteed that it will even exist perhaps).
How can I get around this so that I can display my images programmatically or is there a better solution?
Here's the source:
<asp:ListView ID="ListView_Comments" runat="server"
DataKeyNames="ReviewID,ProductID,Rating" DataSourceID="EDS_CommentsList">
<ItemTemplate>
<tr style="background-color:#EDECB3;color: #000000;"> <td><%# Eval("CustomerName") %></td>
<td> <img src='Styles/Images/ReviewRating_d<%# Eval("Rating") %>.gif' alt="">
<br />
</td>
<td> <%# Eval("Comments") %>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color:#F8F8F8;"> <td><%# Eval("CustomerName") %></td>
<td>
<img id="rateImage" src="" alt="" runat="server" />
......
Should be able to access it in the codebehind in the OnItemDatabound Event. There u can check to see if its an alternating item or not then use FindControl and u should have access to it.
Or, if your image is stored in your datasource y not just set the src using <%# Eval %>