Hi,
I have this in my articles.ascx.vb - calling from xml file.
Partial Class articleDefault
Inherits System.Web.UI.UserControl
Public Function getArticleAuthor() As String
Return IIf(XPath("article/author"
) = "", "", "By " & XPath("article/author") & " " & XPath("summary") & ":: Published: "& XPath("article/pubDate") & ". ")
End Function
Public Function getPubDate() As String
Return IIf(XPath("pubDate") = "", "<dd> ", "<dd class=""smaller""> " & XPath("pubDate") & " ")
End Function
Public Function getSummary() As String
Return IIf(XPath("summary") = "", "", "<dd> " & XPath("summary") & " <br class=""clearfloat"" /></dd>")
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
I read that using IIF in VB is quirky and very slow. So I am trying to switch to this:
Partial Class articleDefault
Inherits System.Web.UI.UserControl
Public Function getArticleAuthor() As String
Dim value As String = XPath("article/author")
If value is Nothing Then
Return "empty"
Else
Return "By " & XPath("article/author") & " " & XPath("summary") & ":: Published: "& XPath("article/pubDate") & ". "
End If
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class
It is working but I just wanted my code checked - I am very new to this. Is there a better /more efficient way to do this? IF so advise is greatly appreciated.
I was going to do the change to each public function.
Cheers
Tania
Start Free Trial