Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Urgent code needed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
slinky - 14 Jun 2007 20:54 GMT
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 - 14 Jun 2007 21:01 GMT
check out this. He's doing exactly what you need:

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

> 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
[quoted text clipped - 31 lines]
>    End Sub
> </script>
slinky - 14 Jun 2007 21:22 GMT
I use vb.net and know very little about C#

> check out this. He's doing exactly what you need:
>
[quoted text clipped - 37 lines]
>
> - Show quoted text -
Alexey Smirnov - 14 Jun 2007 21:53 GMT
> I use vb.net and know very little about C#
>
[quoted text clipped - 45 lines]
>
> - 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>
bruce barker - 14 Jun 2007 21:15 GMT
move the onload code to oninit and take out the IsPostBack test.

-- bruce (sqlwork.com)

> 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
[quoted text clipped - 31 lines]
>     End Sub
> </script>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.