I'm working on a rss feed reader and seems so work great.
The only thing that I seem not to get working is to read the image in the feed.
<itunes:image href="http://www.itunes.com/image.jpg"/>
Can anyone help?
This is a part of my code.
For Each objItem in objItems
On Error Resume Next
TheTitle = objItem.selectSingleNode("title").Text
TheLink = objItem.selectSingleNode("image").Text
Theimg = objItem.SelectSingleNode("itunes").Attributes(":image").InnerText
Response.Write "<div class='article'>" &_
"<a href=" & TheLink & ">" & _
"<span>" & Theimg & TheTitle & "</span>" & _
"</a>" & _
"</div>"
Next
Your image address needs to go inside an image tag
Response.Write "<div class=""article"">" &_
"<a href=""" & TheLink & """>" & _
"<img src=""" & Theimg & """ alt=""" & TheTitle & """ />" & _
"</a>" & _
"</div>"
If you're wondering why all the double quotes, see this question
Adding quotes to a string in VBScript
As an aside, if you understand XSL then I find that the best way to handle RSS feeds in Classic ASP is to do a server side XSLT transformation. The ASP looks like this
set xml = Server.CreateObject("Msxml2.DomDocument.6.0")
xml.setProperty "ServerHTTPRequest", true
xml.async = false
xml.validateOnParse = false
xml.load("http://your-rss-feed")
set xsl = Server.CreateObject("Msxml2.DomDocument.6.0")
xsl.load(Server.Mappath("yourxslfile.xsl"))
Response.Write(xml.transformNode(xsl))
set xsl = nothing
set xml = nothing
Related
I'm working on a ASP (Within the payment gateway). The options in the drop down at being pulling in from a database. I can't touch the database so have to attack the matter from the code.
Here is the value name that I need to exclude _01BM(Q)
Here is the code for the drop down.
<select name="programgroup" onchange="onProgramGroup()">
<% Call buildDropDownList(strProgramGroupCode, rsProgramGroup, "ProgramGroupCode", "ProgramGroupDescription", False)%>
</select>
I would really appreciate any help on this guys.
Here is the code for the method:
Sub buildDropDownList(strCurrentSelection, objListData, strCodeName, strDescriptionName, blnIncludeOther)
If Not objListData.BOF Then
objListData.MoveFirst
End If
While Not objListData.EOF
Response.Write "<option value='" & objListData(strCodeName) & "' "
If StrComp(strCurrentSelection, objListData(strCodeName),1) = 0 then
Response.Write "selected"
End If
Response.Write ">" & objListData(strDescriptionName) & "</option>" & VbCrLf
objListData.MoveNext
Wend
if blnIncludeOther then
Response.Write "<option value='<Other>' "
If strCurrentSelection <> "" and InStr(1, "<Other>", strCurrentSelection) = 1 then
Response.Write "selected"
End If
Response.Write ">Other</option>" & VbCrLf
end if
End Sub
You will have to change the method building the drop down. Since you did not provide us with the code for it, I'll give you a skeleton, and can use it to change your actual code.
To make it more generic and less ugly, better pass the value(s) to exclude to the method, as an array, instead of hard coding them in there.
So, the method should look like this:
Sub buildDropDownList(strProgramGroupCode, rsProgramGroup, someParamHere, anotherParam, boolParam, arrValuesToExclude)
Dim excludedValuesMapping, x
Set excludedValuesMapping = Server.CreateObject("Scripting.Dictionary")
For x=0 To UBound(arrValuesToExclude)
excludedValuesMapping.Add(LCase(arrValuesToExclude(x)), True)
Next
'...unknown code here...
Do Until rsProgramGroup.EOF
strCurrentValue = rsProgramGroup(valueFieldName)
If excludedValuesMapping.Exists(LCase(strCurrentValue)) Then
'value should be excluded, you can do something here, but not write it to browser
Else
strCurrentText = rsProgramGroup(textFieldName)
Response.Write("<option value=""" & Replace(strCurrentValue, """", """) & """>" & strCurrentText & "</option>")
End If
rsProgramGroup.MoveNext
Loop
End Sub
And to use it:
<% Call buildDropDownList(strProgramGroupCode, rsProgramGroup, "ProgramGroupCode", "ProgramGroupDescription", False, Array("_01BM(Q)"))%>
Now having your code, and if you don't want to make it generic, you can also ignore specific values by having such code in the buildDropDownList sub:
Dim currentCodeValue
While Not objListData.EOF
currentCodeValue = objListData(strCodeName)
If (UCase(currentCodeValue)<>"_04GIDBM") And _
(UCase(currentCodeValue)<>"_05GIDFM") And _
(UCase(currentCodeValue)<>"_08EXHRM") And _
(UCase(currentCodeValue)<>"_10EXMKT") And _
(UCase(currentCodeValue)<>"_12EXTTH") And _
(UCase(currentCodeValue)<>"_17EXHSC") Then
Response.Write "<option value='" & currentCodeValue & "' "
If StrComp(strCurrentSelection, currentCodeValue, 1) = 0 then
Response.Write "selected"
End If
Response.Write ">" & objListData(strDescriptionName) & "</option>" & VbCrLf
End If
objListData.MoveNext
Wend
This will just skip any records with such values, and will not output a drop down option for them.
Need some expertise here.
I want to achieve the output similar to the one attached as a image. This snapshot format I was able to achieve using <UL> & <LI> (see code below) tags which was formed in the ASP.NET code behind on the load of page. The below was displayed in the div tag <div id="catDisplay" class="catDisplay" runat="server"></div>
strDataString.Append("")
strDataString.AppendLine("<ul class='categories'>")
Do While objDataReader.Read
intCategoryID = objDataReader.GetValue(0).ToString()
strCategoryName = objDataReader.GetValue(1).ToString()
strCategoryImage = objDataReader.GetValue(2).ToString()
If Len(Trim(strCategoryImage)) = 0 Or String.IsNullOrEmpty(Trim(strCategoryImage)) = True Or String.IsNullOrWhiteSpace(Trim(strCategoryImage)) = True Then
strCategoryImageWithPath = "Images/noimage.png"
Else
strCategoryImageWithPath = "base_Clients/" & intAccountID.ToString() & "/Category/" & strCategoryImage.ToString()
End If
intSortSequence = objDataReader.GetValue(3).ToString()
intCategoryStatus = objDataReader.GetValue(4).ToString()
If Trim(intCategoryStatus) = 0 Then
setCategoryStatus = "Inactive"
End If
strDataString.Append("<li id='li_" & i & "'>")
strDataString.Append("<div class='liContents'>")
strDataString.Append("<span class='catImage'><img src='" & strCategoryImageWithPath.ToString() & "' alt='" & strCategoryName.ToString() & "' width='200' height='131' /></span>")
strDataString.Append("<span class='catContentsBar'></span>")
strDataString.Append("<span class='catTitle' title='Category Name: " & strCategoryName.ToString() & "' >" & strCategoryName.ToString() & "</span>")
strDataString.Append("<span class='catStatus' title='Category Status'>" & setCategoryStatus & "</span>")
strDataString.Append("<span class='catSort' title='Category Sort Sequence is " & intSortSequence.ToString() & "' >" & intSortSequence.ToString() & "</span>")
' the below is for the Edit and Delete Button
strDataString.Append("<span id='nav_" & i & "' class='navigation'>")
strDataString.Append("<button id='btnInsert_" & i & "' type='button' class='SmallButtonWithImage' title='Add New Category' onClick='fn_CategoryManagement(1, 0)'>")
strDataString.Append("<img src='Images/menuicons/add.png' alt='Add' hspace='2' />")
strDataString.Append("</button>")
strDataString.Append("<button id='btnEdit_" & i & "' type='button' class='SmallButtonWithImage' title='Edit Category: " + strCategoryName.ToString() + "' onClick='fn_CategoryManagement(2, """ & intCategoryID.ToString() & """)'>")
strDataString.Append("<img src='Images/menuicons/edit.gif' alt='Edit' hspace='2' />")
strDataString.Append("</button>")
strDataString.Append("<button id='btnDelete_" & i & "' type='button' class='SmallButtonWithImage' title='Delete Category: " & strCategoryName.ToString() & "' onClick='fn_DeleteConfirm(""" & intCategoryID.ToString() & """)'>")
strDataString.Append("<img src='Images/menuicons/delete.png' alt='Delete' hspace='2' />")
strDataString.Append("</button>")
strDataString.Append("</span>")
strDataString.Append("</div>")
strDataString.Append("</li>")
i = i + 1
Loop
strDataString.AppendLine("</ul>")
Initially, due to time constraints, I had to opt for this. It is difficult to manage the above code. Can anyone suggest me what is the best control with some example URLs (not necessarily directly related) in ASP.NET should I use to achieve the same output with full accessibility to CSS3.
Appreciate.
I would suggest either one from below
ListView control, check this Article
Repeater control
Inline syntax with for-each (Tough to ready and easy to modify layout)
I tried everything, but nothing seems to work!
How the do I put a breakline?!
Dim textMsg as String
textMsg = Body.text & Environment.Newline & _ q1.text & Environment.Newline & _ q2.text & Environment.Newline & _ q3.text & Environment.Newline & _ q4.text '
please help
(with corrent code I get an error cuz of the & Environment.Newline & _ ")
Since you tagged this asp.net, I'll guess that this newline should appear in a web page. In that case, you need to remember that you are creating html rather than plain text, and html ignores all whitespace... including newlines. If you view the source for your page, you'll likely see that the new lines do make it to your html output, but they are ignored, and that's what is supposed to happen. If you want to show a new line in html, use a <br> element:
textMsg = Body.text & "<br>" & _ q1.text & "<br>" & _ q2.text & "<br>" & _ q3.text & "<br>" & _ q4.text
The code above will place the text on several lines. It's interesting that if you view the source now, you'll see that everything is all on the same line, even though it uses several lines for display.
You should add a br:
textMsg = Body.text & "<BR/>" & _ q1.text & "<BR/>" & _ q2.text & "<BR/>" & _ q3.text & "<BR/>" & _ q4.text
Or you can try:
Str & VBNewLine OR Str & VBCrLf
Or set the email message to html. The the will work.
thats the right one:
& (vbCrLf) &
Try this:
dim textMsg as String
textMsg = Body.text & vbNewLine
I preffer .Net Style:
& Environment.NewLine &
It's Is exactly the same that
& (vbCrLf) &
This my code
Dim verifyUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) & Page.ResolveUrl("~/verify.aspx?ID=" & sGUID)
mail.Body = "<html>" & _
"<head>" & _
"<meta http-equiv=""Content-Language"" content=""fr"">" & _
"<meta http-equiv=""Content-Type"" content=""text/html; charset=windows-1252"">" & _
"</head>" & _
"<body>" & _
" <p>Hello, <%UserName%>. You are receiving this email because you recently created a new account at my" & _
"site. Before you can login, however, you need to first visit the following link:</p>" & _
"<p> //////Here put an href whit the value verifyUrl ///// </p>" & _
"</body>" & _
"</html>"
mail.Body = mail.Body.Replace("<%VerifyUrl%>", verifyUrl)
mail.Body = mail.Body.Replace("<%UserName%>", nom)
Try for long time to put an like <a href"<%verifyUrl%>"</a> but this not work well................
Please help me to enter this simple html line!!!
Thanks in advance!!
You can use this:
<a href='<%VerifyUrl%>'>Click Here</a>
I'm debugging some ASP code and I need to get a quick printout of the current Request datastructure, which I believe is an array of key/value pairs.
I see that Request.Form("key") is the method for extracting individual elements.
Any tips on printing out the entire thing?
Try this
For Each item In Request.Form
Response.Write "Key: " & item & " - Value: " & Request.Form(item) & "<BR />"
Next
Working:
For x = 1 to Request.Form.Count
Response.Write x & ": " _
& Request.Form.Key(x) & "=" & Request.Form.Item(x) & "<BR>"
Next
I have other Classic ASP code snippets here:
https://github.com/RaviRamDhali/programming-procedure/tree/master/Snippets/ASP
Try a FOR/EACH loop:
for each x in Request.Form
Response.Write(x)
Next