Friday, January 13, 2012

Update data using Admin Panel

write code at the Admin Page 
Add Namespace and add the XML file by Solution Explorer
*********************
Imports System.Xml
Imports System.Web
**********************
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim strxmlpath As String = Server.MapPath("../database/col.xml")
            Dim doc As New XmlDocument
            doc.Load(strxmlpath)
            Dim node As XmlNode = doc.DocumentElement.FirstChild
            node.InnerText = Editor1.Content.ToString  //add the editor on the page
            doc.Save(strxmlpath)
        Catch ex As Exception
            Response.Write(ex.Message)

        End Try
    End Sub
    Public Function xmlshwo2()
        Try
            Dim strxmlpath1 As String = Server.MapPath("../database/col.xml")
            Dim doc As New XmlDocument
            doc.Load(strxmlpath1)
            Dim elem As XmlNode = doc.DocumentElement.FirstChild
            Editor1.Content = elem.InnerText
            doc.Save(strxmlpath1)
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            xmlshwo2()
        End If
    End Sub
write the code on  client  page

Public Function xmlshow1()
        Try
            Dim strxmlpath As String = Server.MapPath("~/database/col.xml")
            Dim doc As New XmlDocument
            doc.Load(strxmlpath)
            Dim elem As XmlNode = doc.DocumentElement.FirstChild
            Label1.Text = elem.InnerText
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        xmlshow1()
    End Sub