ASP.NET / C#WebForm中的HTML文件编辑器 [英] HTML File Editor from ASP.NET/C# WebForm

查看:100
本文介绍了ASP.NET / C#WebForm中的HTML文件编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我不是开发人员,但我使用C#做了一些ASP.NET工作,我这个小App这基本上是我们公司员工注册的EULA。



EULA我正在使用以下内容从HTML文件将其加载到Literal控件:



Hello,

I'm not a Dev per say but I've done some work w/ ASP.NET using C#, I've this little App that's basically a EULA for our Company's Employees to signup.

The EULA I'm currently loading it to a Literal control from a HTML file using something like this:

string Policy = String.Empty;
//Sets the Policy path on the Application
string PolicyFile = HttpContext.Current.Server.MapPath("~/Policy/ITPolicy.htm");
//Read the Policy.htm file
Policy = File.ReadAllText(PolicyFile, Encoding.UTF8);
//Load the ITPolicy.htm file into the Literal Control
this.Literal1.Text = Policy;





现在这对我有用,因为我不想让它太复杂化。但我希望有一个允许我从WebApp本身修改HTML文件的WebForm,我做了一些研究,然后我去尝试了Ajax HtmlEditorExtender,但它根本没有保存我的更改。我想知道我是否遗漏了代码上的内容。



这是HTML编辑器表单的代码隐藏:





Now that works for me as I don't want to complicate it so much. But I would like to have a WebForm that allows me to modify that HTML file on the go from the WebApp itself, I did some research and I went and tried Ajax HtmlEditorExtender, but it doesn't save my changes at all. I was wondering if I'm missing something on the code.

Here's my Codebehind for that HTML Editor Form:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Principal;
using System.Net.Security;
using System.Net.Mail;
using System.IO;
using System.Text;
using System.Net;

public partial class IT_ITPolicy_Editor : System.Web.UI.Page
{
    string PolicyFile = HttpContext.Current.Server.MapPath("~/Policy/ITPolicy2.htm");

    protected void Page_Load(object sender, EventArgs e)
    {
        if (File.Exists(PolicyFile))
        {
            StreamReader sr = new StreamReader(PolicyFile, true);
            TextBox1.Text = sr.ReadToEnd();
            sr.Close();
        }
        else
        {
            Response.Write("<script>alert('Couldn't load the IT Policy file')</script>");
        }  
    }

    //Button2_Click is supposed to Save the changes made to the HMTL file...
    protected void Button2_Click(object sender, EventArgs e)
    {
        StreamWriter wr = new StreamWriter(PolicyFile, false);
        wr.Write(TextBox1.Text.ToString());
        wr.Close();
        Response.Redirect("~/Default.aspx");
    }
}





我感谢您对此事的任何帮助。我只想简单地允许编辑文件并直接从应用程序保存更改。



非常感谢,



Ray



I appreciate any help on this matter. I just want to simply allow editing the file and saving the changes right from the Application.

Thanks in advence,

Ray

推荐答案

提醒您为策略文件的IUSR用户授予适当的权限。
Remind to give appropriate rights to the IUSR user for the policy file.


这篇关于ASP.NET / C#WebForm中的HTML文件编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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