小编Sll*_*lix的帖子

c#中的多个附件

我在程序中发送多个附件时遇到问题.

在我尝试添加多个附件之前,我没有遇到任何问题.所以我改变了代码,它停止了工作.

创建附件: 未添加所有代码以使其更易于查看.

Attachment attachment = getAttachment(bodyFile, "Formulier" + counter + ".doc");
attachments.Add(attachment);
//attachment.Dispose();

if (attachments != null)
{
  foreach (Attachment attachment in attachments)
  {
    email.Attachments.Add(attachment);
  }
}    
Run Code Online (Sandbox Code Playgroud)

得到附件

private Attachment getAttachment(string bodyFile, string title)
{
  return createDocument(bodyFile, title);
}
Run Code Online (Sandbox Code Playgroud)

创建文件

private Attachment createDocument(string bodyFile, string title) 
{
  string activeDir = HttpContext.Current.Server.MapPath("/Tools");
  string newPath = Path.Combine(activeDir, "Documents");

  Directory.CreateDirectory(newPath);
  newPath = Path.Combine(newPath, title);

  FileStream fs = File.Create(newPath);
  fs.Close();
  File.WriteAllText(newPath, bodyFile);

  var fstemp = new FileStream(newPath, FileMode.Open, FileAccess.Read);
  return new Attachment(fstemp, …
Run Code Online (Sandbox Code Playgroud)

c# email-attachments asp.net-mvc-3

5
推荐指数
1
解决办法
2793
查看次数

如何使用Javascript将HTML表单数据输出到XML文件?

我目前正在试图弄清楚如何将我的HTML表单数据输出到XML文件.这是我过去几天一直在玩的一个想法,以便创建一个autounattended.xml文件,用于Windows 7安装.

目前我的HTML如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Windows 7 Answer File Generator</title>
    </head>
    <body>
        <form>
            <h1>Windows 7 Answer File Generator</h1>
            <h2>General Settings</h2>
            <table>
                <tr>
                    <td width="200px">Skip product key:</td>
                    <td>
                        <select name="SkipProductKey">
                            <option value="Yes" selected="selected">Yes</option>
                            <option value="No">No</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td width="200px">Skip automatic activation:</td>
                    <td>
                        <select name="SkipAutoActivation">
                            <option value="Yes" selected="selected">Yes</option>
                            <option value="No">No</option>
                        </select>
                    </td>
                </tr>
            </table>
        </body>
    </html>
Run Code Online (Sandbox Code Playgroud)

这只是我一直在努力的片段.所以,我想知道是否可以使用javascript根据选择值创建XML文件,并询问用户在哪里保存xml文件.有关这方面的任何信息将是一个很大的帮助.

html javascript xml forms

3
推荐指数
1
解决办法
2万
查看次数

表单提交后将字典从视图传递到控制器

剃刀视图:

@using (Html.BeginForm("Move", "Details", new { dict= dictionary}, FormMethod.Post)) {
    //table with info and submit button
    //dictionary => is a dictionary of type <Sales_Order_Collected, string>
}
Run Code Online (Sandbox Code Playgroud)

控制器动作:

[HttpPost]
public string Move(Dictionary<Sales_Order_Collected, string> dict) {
    return "";
}
Run Code Online (Sandbox Code Playgroud)

有没有办法将模型字典传递给控制器​​?因为我的参数始终为空。

routevalues razor asp.net-mvc-3

3
推荐指数
1
解决办法
4151
查看次数

发布表单后,从服务器获取json到jQuery

可能重复:
JQuery Ajax返回值

当我填写登录/注册表单时,服务器将我发送到Json页面.我尝试将json转换为js/jquery文件,而不重定向到该页面.

有人能告诉我如何获取json数据吗?

为了解释我的意思,我向您展示了一些代码+ html页面.

Html表格:

<form id="registerForm" action="http://localhost:8081/rest/users/register" method="post" >
<table>
    <tr>
        <td>
            <label for="firstname" class="normalFont"><span rel="localize[register.firstname]">First name</span></label>
        </td>
        <td>
            <input id="firstname" name="firstname" type="text" class="required">
        </td>
        <td class="status">

        </td>
    </tr>

    ... (some other fields)

    <tr>
        <td>
            <input type="submit" value="Register">
        </td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

服务器:

@Override
@RequestMapping(value="/register", method = RequestMethod.POST)
public @ResponseBody Message register(String firstname, String lastname, String username, String password, String email, String address, String zip, String city, String country) {

    try
    {
        User user = new User(); …
Run Code Online (Sandbox Code Playgroud)

jquery post json

2
推荐指数
1
解决办法
1291
查看次数