TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chinni
NA
79
5.7k
image tag URL dynamically
Aug 16 2013 4:11 AM
Hi,
i develop a images gallery application for that i use a img tag and anchor tag i need get a anchor tag and image tag URL are dynamically can you help me
<asp:DataList ID="usergalleryDataList" RepeatColumns="8" runat="server">
<ItemTemplate>
<a href='<%#Session["dir"]%>' rel="prettyPhoto[pp_gal]" id="anchor">
<img src='<%#Session["dir"]%>' width="60" height="60" alt='<%# Eval("Name") %>' />
</a>
</ItemTemplate>
</asp:DataList>
Thanks,
Ajith.
Reply
Answers (
21
)
0
Iftikar Hussain
0
12.6k
449.2k
Aug 17 2013 12:07 PM
ok. are you able to get correct image path with name in your code without displaying to datalist?
0
Chinni
0
79
5.7k
Aug 17 2013 11:58 AM
no, am not saved image names in database just i need to retrieve from folder
0
Iftikar Hussain
0
12.6k
449.2k
Aug 17 2013 10:26 AM
the image name is saved in database?
0
Chinni
0
79
5.7k
Aug 17 2013 10:20 AM
i am declare image name i need to pick the image names from the folder and display the all images list in data list in above example also am not declare image names it pic the all names from folder
0
Iftikar Hussain
0
12.6k
449.2k
Aug 17 2013 7:45 AM
but where you are declare the image name. give example
0
Chinni
0
79
5.7k
Aug 17 2013 4:24 AM
Two pages in the application are one home and the next one sub Home. Home page have two text boxes and two radio buttons in the first text box for main folder name in image folder, the second text box for sub folder name like flowers/rose flower is main folder in image folder rose in sub folder of flower this is folder structure now these two names assign to session and find the location of the folder if folders are available in image folder then display the images in page this is the complete picture
0
Iftikar Hussain
0
12.6k
449.2k
Aug 17 2013 3:54 AM
what output you are getting? Still I am not clear which path you want to set it?
0
Chinni
0
79
5.7k
Aug 17 2013 3:07 AM
not working same output
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 10:21 AM
try like this
public string GetPath()
{
if (Session["strSrc"] != null)
{
string path = "~/Source/" + Session["strSrc"].ToString();
DirectoryInfo myImageDir = new DirectoryInfo(Server.MapPath(path));
return myImageDir.ToString();
}
else
{
return "";
}
}
Regards,
Iftikar
0
Chinni
0
79
5.7k
Aug 16 2013 7:57 AM
//string ss; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["strSrc"] != null) { hdfsessionPath.Value = "../"+Session["strSrc"].ToString(); } else return; string path = "~/Source/" + Session["strSrc"].ToString(); DirectoryInfo myImageDir = new DirectoryInfo(Server.MapPath(path)); Session["dir"] = myImageDir.ToString(); //ss = Session["dir"].ToString() + "\\"; try { usergalleryDataList.DataSource = myImageDir.GetFiles(); usergalleryDataList.DataBind(); } catch (System.IO.DirectoryNotFoundException) { Response.Write(" alert('Error!');"); } } // GetPath(); } public string GetPath() { return Session["dir"].ToString(); } }
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 6:32 AM
share me the code for GetPath()
0
Chinni
0
79
5.7k
Aug 16 2013 6:08 AM
yes i removed from page load but same output i need to assign the path to like images/screen/{0} in my session variable have path like images/screen/
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 5:59 AM
wrong, you need to call
GetPath()
from aspx not from page load
<asp:DataList ID="usergalleryDataList" RepeatColumns="8" runat="server">
<ItemTemplate>
<a href='<%#
GetPath()
%>' rel="prettyPhoto[pp_gal]" id="anchor">
<img src='<%#
GetPath()
%>' width="60" height="60" alt='<%# Eval("Name") %>' />
</a>
</ItemTemplate>
</asp:DataList>
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 5:32 AM
then call a method from aspx and build the path with your condition and return it
<asp:DataList ID="usergalleryDataList" RepeatColumns="8" runat="server">
<ItemTemplate>
<a href='<%# GetPath() %>' rel="prettyPhoto[pp_gal]" id="anchor">
<img src='<%# GetPath() %>' width="60" height="60" alt='<%# Eval("Name") %>' />
</a>
</ItemTemplate>
</asp:DataList>
public string GetPath()
{
build your path and return it
}
Regards,
Iftikar
0
Chinni
0
79
5.7k
Aug 16 2013 5:17 AM
just path only like images/screen/ i need to take file names from folder
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 5:10 AM
then assign the path as images/screen/imagename.jpg to the session variable
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 4:55 AM
you are not saving the path which you have entered in the textbox?
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 4:32 AM
You need to use your application folder image path
0
Chinni
0
79
5.7k
Aug 16 2013 4:32 AM
actual url is
<
a
href
='
<%
# Eval("Name","images/screen/{0}")
%>
'
rel
="prettyPhoto[pp_gal]
">
<
img
src
='
<%
# Eval("Name","images/screen/{0}")
%>
'
width
="60"
height
="60"
alt
='
<%
# Eval("Name")
%>
'
/>
this is working but i need to dynamic path every time i entered my path in text box and check the path if path is a
vailable
i assigned to session this is s
cenario
0
Sanjeeb Lenka
0
15.3k
2.4m
Aug 16 2013 4:32 AM
don't use physical path as when you deploy this it will show error.
create a image folder in solution and store the image into that and
use the code given by iftikar
0
Iftikar Hussain
0
12.6k
449.2k
Aug 16 2013 4:14 AM
Hi,
Have you saved your anchor and image url in database? try like this
<asp:DataList ID="usergalleryDataList" RepeatColumns="8" runat="server">
<ItemTemplate>
<a href='images/Gallery/<%# Eval("Name")%>" id="anchor">
<img src='images/Gallery/<%# Eval("Name")%>' width="60" height="60" alt='<%# Eval("Name") %>' />
</a>
</ItemTemplate>
</asp:DataList>
Regards,
Iftikar
sum values should be shown in textbox using javascript
Can any 1 help me how to do data driven test using selenium