Urgent code needed

Discussion in 'ASP .Net' started by slinky, Jun 14, 2007.

  1. slinky

    slinky Guest

    I've tried this week everything I can think of to get this code to
    work , can any kind soul take a look at my code and my what should be
    a simple task and help me out. I've looked in books, websites, and
    can't find a solution... thanks!

    I have an aspx for with a textbox and a button. The goal is to simply
    have the user type a message, hit the button and it should append to
    the XML file. I can open the aspx in the browser with no problem, but
    the XML file does not get updated. What's wrong with this code?
    Thanks!

    <script runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    Dim ds As New DataSet()
    ds.ReadXml(Server.MapPath("timeline.xml"))
    txtNewEvent.DataBind()
    ds.Dispose()
    End If
    End Sub


    Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSubmit.Click
    Dim ds As New DataSet()
    Try
    ds.ReadXml(Server.MapPath("timeline.xml"))
    ds.Tables(0).Rows(0).Item("Event") = txtNewEvent.Text
    ds.WriteXml(Server.MapPath("timeline.xml"))
    Catch
    Finally
    ds.Dispose()
    End Try
    End Sub
    </script>
     
    slinky, Jun 14, 2007
    #1
    1. Advertising

  2. slinky

    Mike Guest

    check out this. He's doing exactly what you need:

    http://www.developer.com/net/csharp/article.php/3489611


    "slinky" <> wrote in message
    news:...
    > I've tried this week everything I can think of to get this code to
    > work , can any kind soul take a look at my code and my what should be
    > a simple task and help me out. I've looked in books, websites, and
    > can't find a solution... thanks!
    >
    > I have an aspx for with a textbox and a button. The goal is to simply
    > have the user type a message, hit the button and it should append to
    > the XML file. I can open the aspx in the browser with no problem, but
    > the XML file does not get updated. What's wrong with this code?
    > Thanks!
    >
    > <script runat="server">
    > Private Sub Page_Load(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles MyBase.Load
    > If Not IsPostBack Then
    > Dim ds As New DataSet()
    > ds.ReadXml(Server.MapPath("timeline.xml"))
    > txtNewEvent.DataBind()
    > ds.Dispose()
    > End If
    > End Sub
    >
    >
    > Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles btnSubmit.Click
    > Dim ds As New DataSet()
    > Try
    > ds.ReadXml(Server.MapPath("timeline.xml"))
    > ds.Tables(0).Rows(0).Item("Event") = txtNewEvent.Text
    > ds.WriteXml(Server.MapPath("timeline.xml"))
    > Catch
    > Finally
    > ds.Dispose()
    > End Try
    > End Sub
    > </script>
    >
     
    Mike, Jun 14, 2007
    #2
    1. Advertising

  3. slinky

    bruce barker Guest

    move the onload code to oninit and take out the IsPostBack test.

    -- bruce (sqlwork.com)

    slinky wrote:
    > I've tried this week everything I can think of to get this code to
    > work , can any kind soul take a look at my code and my what should be
    > a simple task and help me out. I've looked in books, websites, and
    > can't find a solution... thanks!
    >
    > I have an aspx for with a textbox and a button. The goal is to simply
    > have the user type a message, hit the button and it should append to
    > the XML file. I can open the aspx in the browser with no problem, but
    > the XML file does not get updated. What's wrong with this code?
    > Thanks!
    >
    > <script runat="server">
    > Private Sub Page_Load(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles MyBase.Load
    > If Not IsPostBack Then
    > Dim ds As New DataSet()
    > ds.ReadXml(Server.MapPath("timeline.xml"))
    > txtNewEvent.DataBind()
    > ds.Dispose()
    > End If
    > End Sub
    >
    >
    > Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) Handles btnSubmit.Click
    > Dim ds As New DataSet()
    > Try
    > ds.ReadXml(Server.MapPath("timeline.xml"))
    > ds.Tables(0).Rows(0).Item("Event") = txtNewEvent.Text
    > ds.WriteXml(Server.MapPath("timeline.xml"))
    > Catch
    > Finally
    > ds.Dispose()
    > End Try
    > End Sub
    > </script>
    >
     
    bruce barker, Jun 14, 2007
    #3
  4. slinky

    slinky Guest

    I use vb.net and know very little about C#


    On Jun 14, 4:01 pm, "Mike" <> wrote:
    > check out this. He's doing exactly what you need:
    >
    > http://www.developer.com/net/csharp/article.php/3489611
    >
    > "slinky" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > I've tried this week everything I can think of to get this code to
    > > work , can any kind soul take a look at my code and my what should be
    > > a simple task and help me out. I've looked in books, websites, and
    > > can't find a solution... thanks!

    >
    > > I have an aspx for with a textbox and a button. The goal is to simply
    > > have the user type a message, hit the button and it should append to
    > > the XML file. I can open the aspx in the browser with no problem, but
    > > the XML file does not get updated. What's wrong with this code?
    > > Thanks!

    >
    > > <script runat="server">
    > > Private Sub Page_Load(ByVal sender As System.Object, _
    > > ByVal e As System.EventArgs) Handles MyBase.Load
    > > If Not IsPostBack Then
    > > Dim ds As New DataSet()
    > > ds.ReadXml(Server.MapPath("timeline.xml"))
    > > txtNewEvent.DataBind()
    > > ds.Dispose()
    > > End If
    > > End Sub

    >
    > > Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    > > ByVal e As System.EventArgs) Handles btnSubmit.Click
    > > Dim ds As New DataSet()
    > > Try
    > > ds.ReadXml(Server.MapPath("timeline.xml"))
    > > ds.Tables(0).Rows(0).Item("Event") = txtNewEvent.Text
    > > ds.WriteXml(Server.MapPath("timeline.xml"))
    > > Catch
    > > Finally
    > > ds.Dispose()
    > > End Try
    > > End Sub
    > > </script>- Hide quoted text -

    >
    > - Show quoted text -
     
    slinky, Jun 14, 2007
    #4
  5. On Jun 14, 10:22 pm, slinky <> wrote:
    > I use vb.net and know very little about C#
    >
    > On Jun 14, 4:01 pm, "Mike" <> wrote:
    >
    >
    >
    > > check out this. He's doing exactly what you need:

    >
    > >http://www.developer.com/net/csharp/article.php/3489611

    >
    > > "slinky" <> wrote in message

    >
    > >news:...

    >
    > > > I've tried this week everything I can think of to get this code to
    > > > work , can any kind soul take a look at my code and my what should be
    > > > a simple task and help me out. I've looked in books, websites, and
    > > > can't find a solution... thanks!

    >
    > > > I have an aspx for with a textbox and a button. The goal is to simply
    > > > have the user type a message, hit the button and it should append to
    > > > the XML file. I can open the aspx in the browser with no problem, but
    > > > the XML file does not get updated. What's wrong with this code?
    > > > Thanks!

    >
    > > > <script runat="server">
    > > > Private Sub Page_Load(ByVal sender As System.Object, _
    > > > ByVal e As System.EventArgs) Handles MyBase.Load
    > > > If Not IsPostBack Then
    > > > Dim ds As New DataSet()
    > > > ds.ReadXml(Server.MapPath("timeline.xml"))
    > > > txtNewEvent.DataBind()
    > > > ds.Dispose()
    > > > End If
    > > > End Sub

    >
    > > > Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    > > > ByVal e As System.EventArgs) Handles btnSubmit.Click
    > > > Dim ds As New DataSet()
    > > > Try
    > > > ds.ReadXml(Server.MapPath("timeline.xml"))
    > > > ds.Tables(0).Rows(0).Item("Event") = txtNewEvent.Text
    > > > ds.WriteXml(Server.MapPath("timeline.xml"))
    > > > Catch
    > > > Finally
    > > > ds.Dispose()
    > > > End Try
    > > > End Sub
    > > > </script>- Hide quoted text -

    >
    > > - Show quoted text -- Hide quoted text -

    >
    > - Show quoted text -


    <%@ Import Namespace="System.Data" %>
    <script language="vb" runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    Dim ds As New DataSet()
    ds.ReadXml(Server.MapPath("timeline.xml"))
    'txtNewEvent.DataBind()
    ds.Dispose()
    End If
    End Sub


    Private Sub btnSubmit_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnSubmit.Click
    Dim ds As New DataSet()
    'Try
    ds.ReadXml(Server.MapPath("timeline.xml"))
    ds.Tables(0).Rows(0).Item("Event") = "it works"
    ds.WriteXml(Server.MapPath("timeline.xml"))
    'Catch
    'Finally
    ds.Dispose()
    'End Try
    End Sub


    </script>
    <form id=form1 runat=server>
    <asp:button id="btnSubmit" runat="server" text="Button" />
    </form>

    <?xml version="1.0" standalone="yes"?>
    <xml>
    <DataObjects>
    <Event>it works</Event>
    </DataObjects>
    </xml>
     
    Alexey Smirnov, Jun 14, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. andy

    urgent help needed !

    andy, Jul 12, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    912
  2. Sachin Jagtap

    URGENT !! QUEUE STL PROBLEM URGENT!!

    Sachin Jagtap, Apr 28, 2005, in forum: C++
    Replies:
    4
    Views:
    1,045
    Mark Stijnman
    Apr 29, 2005
  3. Rob
    Replies:
    3
    Views:
    440
  4. Rob
    Replies:
    1
    Views:
    82
    Lasse Reichstein Nielsen
    Jun 24, 2004
  5. Replies:
    1
    Views:
    267
Loading...

Share This Page