在 Visual Studio ASPX 中创建联系表单并在单击提交时保存到 XML 文件 [英] Creating a Contact form in Visual Studio ASPX and saving to an XML file when clicking SUBMIT

查看:26
本文介绍了在 Visual Studio ASPX 中创建联系表单并在单击提交时保存到 XML 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿人们希望一切都好..

hey people hope all is well..

我正在尝试使用 ASP 在 VS 中创建一个表单,当提交表单时,详细信息将自动存储在一个 xml 文件中,稍后可以在选定的文件保存路径上访问该文件

i am trying to create a form in VS using ASP that when upon submitting a form the details will get automatically stored in an xml file which can be accessed later on a chosen file save path

我有 2 个文件......Contact.aspx"和Contact.aspx.vb"

i have 2 files ... "Contact.aspx" and "Contact.aspx.vb"

我在Contact.aspx"中创建了表单,当我尝试在contact.aspx.vb"中输入字段时,我不断收到一些错误,例如...

i have created the form in the "Contact.aspx" and when trying to enter the fields in the "contact.aspx.vb" i keep getting several errors such as for example...

错误 5 'Formatting' 不是 'System.Web.UI.WebControls.XmlBuilder' 的成员

Error 5 'Formatting' is not a member of 'System.Web.UI.WebControls.XmlBuilder'

错误 6WriteStartDocument"不是System.Web.UI.WebControls.XmlBuilder"的成员.

Error 6 'WriteStartDocument' is not a member of 'System.Web.UI.WebControls.XmlBuilder'.

错误 7WriteComment"不是System.Web.UI.WebControls.XmlBuilder"的成员.

Error 7 'WriteComment' is not a member of 'System.Web.UI.WebControls.XmlBuilder'.

错误 8WriteStartElement"不是System.Web.UI.WebControls.XmlBuilder"的成员.

Error 8 'WriteStartElement' is not a member of 'System.Web.UI.WebControls.XmlBuilder'.

错误 10WriteAttributeString"不是System.Web.UI.WebControls.XmlBuilder"的成员.

Error 10 'WriteAttributeString' is not a member of 'System.Web.UI.WebControls.XmlBuilder'.

总共有大约 30 个错误......我真的把我的脑袋伸出来尝试了 2 天,但我无法理解我做错了什么我什至尝试了一些在线教程,但错误很多......

there is like 30 errors in total... im literally stuck out my head been trying for 2 days now and can't grasp what im doing wrong ive tried even some of the tutorials online but loads of errors...

希望有人能解决这个问题

hope some1 can fix this

谢谢

推荐答案

您似乎正在尝试使用 XMLWriter.XMLWriter 类位于 System.Xml 命名空间中.尝试导入(或使用)它并再试一次:

It looks like you are trying to use an XMLWriter. The XMLWriter class lives in the System.Xml namespace. Try importing (or using) that and give it another try:

VB:

Imports System.XML

C#:

using System.XML;

示例代码:

XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = ("    ");
using (XmlWriter writer = XmlWriter.Create("books.xml", settings))
{
    // Write XML data.
    writer.WriteStartElement("book");
    writer.WriteElementString("price", "19.95");
    writer.WriteEndElement();
    writer.Flush();
}

这篇关于在 Visual Studio ASPX 中创建联系表单并在单击提交时保存到 XML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆