Can Someon help me to convert C# to Vb this web service code from SlideShow example? I already tried conversion tools and it gives me some errors. Thank You All.
<
scriptrunat="Server"type="text/C#">[System.Web.Services.
WebMethod][System.Web.Script.Services.
ScriptMethod]publicstatic AjaxControlToolkit.Slide[] GetSlides(){
returnnew AjaxControlToolkit.Slide[] {new AjaxControlToolkit.Slide("images/Blue hills.jpg","Blue Hills","Go Blue"),new AjaxControlToolkit.Slide("images/Sunset.jpg","Sunset","Setting sun"),new AjaxControlToolkit.Slide("images/Winter.jpg","Winter","Wintery..."),new AjaxControlToolkit.Slide("images/Water lilies.jpg","Water lillies","Lillies in the water"),new AjaxControlToolkit.Slide("images/VerticalPicture.jpg","Sedona","Portrait style picture")};}
</script>
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
PublicSharedFunction GetPictures()As AjaxControlToolkit.Slide()ReturnNew AjaxControlToolkit.Slide() { _New AjaxControlToolkit.Slide("images/Blue hills.jpg","Blue Hills","Go Blue"), _New AjaxControlToolkit.Slide("images/Sunset.jpg","Sunset","Setting sun"), _New AjaxControlToolkit.Slide("images/Winter.jpg","Winter","Wintery..."), _New AjaxControlToolkit.Slide("images/Water lilies.jpg","Water lillies","Lillies in the water"), _New AjaxControlToolkit.Slide("images/VerticalPicture.jpg","Sedona","Portrait style picture")}End
Function
Ken Tucker:
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
PublicSharedFunction GetPictures()As AjaxControlToolkit.Slide()
ReturnNew AjaxControlToolkit.Slide() { _
New AjaxControlToolkit.Slide("images/Blue hills.jpg","Blue Hills","Go Blue"), _
New AjaxControlToolkit.Slide("images/Sunset.jpg","Sunset","Setting sun"), _
New AjaxControlToolkit.Slide("images/Winter.jpg","Winter","Wintery..."), _
New AjaxControlToolkit.Slide("images/Water lilies.jpg","Water lillies","Lillies in the water"), _
New AjaxControlToolkit.Slide("images/VerticalPicture.jpg","Sedona","Portrait style picture")}
EndFunction
Thank You Ken.
Ken Tucker:
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
PublicSharedFunction GetPictures()As AjaxControlToolkit.Slide()ReturnNew AjaxControlToolkit.Slide() { _New AjaxControlToolkit.Slide("images/Blue hills.jpg","Blue Hills","Go Blue"), _New AjaxControlToolkit.Slide("images/Sunset.jpg","Sunset","Setting sun"), _New AjaxControlToolkit.Slide("images/Winter.jpg","Winter","Wintery..."), _New AjaxControlToolkit.Slide("images/Water lilies.jpg","Water lillies","Lillies in the water"), _New AjaxControlToolkit.Slide("images/VerticalPicture.jpg","Sedona","Portrait style picture")}End
Function
How can I populate this array dynamically? For example, Read some folder with images and create an array?
ForEach sIn Directory.GetFiles(Server.MapPath("my_vacation"),"*.jpg")
Response.write ( Path.GetFileName(s) )
Next
I saw that you answered the dynamic file issue with
ForEach sIn Directory.GetFiles(Server.MapPath("my_vacation"),"*.jpg")
Response.write ( Path.GetFileName(s) )
Next
But how do I get it to dynamically use a value from an SQL table field.
My images have names such as R12345.jpg, R12345_2.jpg, R12345_3.jpg etc...
The listing_id field value is R12345 which would need to replace the "my_vacation" above.
How can I get this to work?
Thanks for your help!
Mike
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MyData.ImagePath = Server.MapPath("~/Images")
Dim strUrl As String = Request.Url.ToString
MyData.Url = strUrl.Substring(0, strUrl.LastIndexOf("/")) & "/Images/"
End Sub
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetPictures() As AjaxControlToolkit.Slide()
Dim di As New DirectoryInfo(MyData.ImagePath)
Dim s(di.GetFiles.Length - 1) As AjaxControlToolkit.Slide
Dim x As Integer = 0
For Each fi As FileInfo In di.GetFiles()
s(x) = New AjaxControlToolkit.Slide(MyData.Url & fi.Name, "", Path.GetFileNameWithoutExtension(fi.Name))
x += 1
Next
Return s
End Function
End Class
Public Class MyData
Private Shared _Path As String
Private Shared _Url As String
Public Shared Property ImagePath() As String
Get
Return _Path
End Get
Set(ByVal value As String)
_Path = value
End Set
End Property
Public Shared Property Url() As String
Get
Return _Url
End Get
Set(ByVal value As String)
_Url = value
End Set
End Property
End Class
AWESOME!
How can I get it to retrieve images at a url other that mine, such as:
http://www.xyz.com/images
Thanks,
Mike
If you have ftp access to the images you can try something like this.
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetFtpPictures() As AjaxControlToolkit.Slide()
Dim ftp As FtpWebRequest = WebRequest.Create("ftp://ftp.xyz.com/images")
ftp.Credentials = New NetworkCredential("YourUserName", "YourPassword")
ftp.Method = WebRequestMethods.Ftp.ListDirectory
Dim wr As WebResponse =ftp.GetResponse
Dim sr As New StreamReader(wr.GetResponseStream)
Dim lst As New List(Of String)
Do While sr.Peek > 0
Dim strOut As String
strOut = sr.ReadLine
lst.Add(strOut)
Loop
Dim s(lst.Count - 1) As AjaxControlToolkit.Slide
Dim x As Integer = 0
For Each str As String In lst
Dim i As Integer = str.IndexOf("."c)
s(x) = New AjaxControlToolkit.Slide("http://www.xyz.com/images/" & str, "", str.Substring(0, i))
x += 1
Next
Return s
End Function
Article on how to use photos stored in Flickr in a slide show
http://www.onteorasoftware.com/blog.aspx?BlogID=75
pashaKasim this site may help you. You may already know about it, but there might be someone out there who hasnt run across this tool yet.
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx
J
Really usefull piece of code.I would like to use a slider control to move across page.For that to be implemented i need to move to the Nth image.Is there a method / way to move to the Nth image.ThanksRain Man Alex
No comments:
Post a Comment