挂钩保存文件对话框
问题描述:
我学习了Tapestry版本5.在那里我建立了一个treemodel,它提供目录中的文件。挂钩保存文件对话框
<t:tree t:id="tree" t:model="stuffModel" t:node="treeNode" t:value="classificationNode">
<p:label>
<t:if test="treeNode.leaf">
<a t:type="EventLink" t:event="leafSelected" t:context="classificationNode.name" t:zone="selectedZone" class="prop:leafClass" href="#"> ${treeNode.label} </a>
</t:if>
<t:if test="!treeNode.leaf">
${treeNode.label}
</t:if>
</p:label>
点击我建立一个StreamResponse中的一个文件(我从那么JumpStart代码中使用的片段(页:http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntypes1)
我的问题,我的问题是我怎么呈现保存文件对话框,这将有助于用户指向下载文件夹。 为了真正下载文件,我必须右键单击然后选择“保存文件为...”?
答
解决方法是删除模板的区域部分,因为这会从服务器返回JSON数据并导致通信处理中断。 相关文章: http://www.mail-archive.com/users%40tapestry.apache.org/msg75396.html
答
添加到您的代码
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// When user clicks button, show the dialog.
saveFileDialog1.ShowDialog();
}
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
{
// Get file name.
string name = saveFileDialog1.FileName;
// Write to the file name selected.
// ... You can write the text from a TextBox instead of a string literal.
File.WriteAllText(name, "test");
}
}
}
答
看起来您在Tapestry邮件列表中找到了答案。对于查看此处的其他人,请参阅http://www.mail-archive.com/[email protected]&q=subject:Re%5C%3A+Save+File+Dialog+after+response+building&o=newest
对不起,队友,它不是C#。这是Java和Tapestry的问题 – hephestos