Script(s)

what I learn is what u c

ASP.Net – XML & Table – 1

leave a comment »

Standard Namespace includes

[%@ Import Namespace = “System.Collections.Hashtable” %]
[%@ Import namespace=”System.Text.regularexpressions” %]
[%@ Import Namespace=”System.Type” %]
[%@ Import Namespace=”System.Data” %]
[%@ Import Namespace=”System.Drawing” %]
[%@ Import namespace=”System.IO” %]
[%@ Import namespace=”System.Text” %]
[%@ Import namespace=”System.Math” %]
[%@ Import namespace=”System.XML” %]

—————————————————————-

Clearing Server Cache  in 1 sec. If specific for variable mention variable name
instead of None.

[%@ outputcache duration=”1″ varybyparam=”None” %]
——————————————————————————————–

Parsing XML document

Dim xdoc as new XMLDataDocument()

Dim allitems as XmlNodeList
Dim childitems as XMLNodelist

Dim attrColl as XmlAttributeCollection
Dim childatts as XmlAttributeCollection

‘Opening the Reference XML file
xdoc.DataSet.ReadXML(server.mappath(“.”) & “/XMLData/StaticRates.xml”)

‘Getting Threshhold Value
ThreshholdNode = xdoc.selectsinglenode(“//cendataProducts/conformingThreshold”)
Threshholdvalue = Convert.ToSingle(ThreshholdNode.innerxml)

— if needed to parse the html inside CData
HomeEquityFooter =
xdoc1.selectsinglenode(“//cendataProducts/homeequityfooter”).innertext

allitems = xdoc.selectNodes(“//cendataProducts/section”)

For i = 0 to allitems.count -1
 attrColl = allitems(i).Attributes

 attrColl(“title”).Value

 childitems = allitems(i).ChildNodes
 For x = 0 to childitems.count-1
  childatts = childitems(x).Attributes
 Next
Next i

——————————————————-

Number Formatting, variable needs to be Single

String.Format(“{0:c0}”,SingleVariable) — Currency conversion
String.Format(“{0:f2}”,SingleVariable) — Decimal 2 places

——————————————————————–
Server side Table instead of controls.

[asp:table id=”tblData” runat=”server” Width=”645px” /]

tblData.Rows.Add(BuildPointDescRow(“col1”, “col2”))

Private Function BuildPointDescRow(ByVal Heading1 As String, ByVal Heading2 As
String) As TableRow
 Dim oRow As New TableRow()
 oRow.Cells.Add(New TableCell())
 With oRow.Cells(0)
  .Font.Name = “Verdana”
  .Font.Size = New FontUnit(8)
  .Width = New Unit(500)
 End With

 oRow.Cells.Add(New TableCell())
 With oRow.Cells(1)
  .Font.Name = “Verdana”
  .Font.Size = New FontUnit(8)
  .Width = New Unit(15)
 End With
 BuildPointDescRow = oRow
End Function

Written by gchandra

March 22, 2005 at 3:47 pm

Posted in Web Coding

Leave a comment