asp.net - HTML file maker demo givers error -



asp.net - HTML file maker demo givers error -

here code works body can guide me how improve code create improve html file used in cms application

please create folder named "images" working

generated html file stored @ project folder

<%@ page language="c#" autoeventwireup="true" codebehind="htmlmaker.aspx.cs" inherits="html5demo.htmlmaker" validaterequest="false" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:scriptmanager id="scriptmanager1" runat="server"> </asp:scriptmanager> <table border="1" cellpadding="5" cellspacing="5"> <tr> <td colspan="2"> <b>html maker</b> </td> </tr> <tr> <td> <asp:label text="title" id="lbltitle" runat="server" /> </td> <td> <asp:textbox runat="server" id="txttitle" /> </td> </tr> <tr> <td> <asp:label text="image" id="lblimage" runat="server" /> </td> <td> <asp:fileupload runat="server" id="fluimage" /> </td> </tr> <tr> <td> <asp:label text="description" id="lbldescription" runat="server" /> </td> <td> <asp:textbox runat="server" id="txtdescription" textmode="multiline" columns="25" rows="5" /> </td> </tr> <tr> <td colspan="2" align="center"> <asp:button text="submit" id="btnsubmit" onclick="btnsubmit_click" runat="server" /> </td> </tr> </table> </div> </form> </body> </html>

.cs file

using system; using system.io; using system.text; public partial class htmlmaker : system.web.ui.page { protected void page_load(object sender, eventargs e) { } protected void btnsubmit_click(object sender, eventargs e) { string imagepath = string.empty; string imagename = string.empty; string filename = server.mappath("~/") + txttitle.text + ".html"; if (fluimage.hasfile) { imagename = datetime.now.tostring("yyyymmddhhmmss") + path.getextension(fluimage.filename); imagepath = server.mappath("~/images/") + imagename; fluimage.saveas(imagepath); } using (filestream fs = new filestream(filename, filemode.create)) { using (streamwriter w = new streamwriter(fs, encoding.utf8)) { w.writeline("<!doctype html>"); w.writeline("<html lang=\"en\">"); w.writeline("<head>"); w.writeline("<title>" + txttitle.text + "</title>"); w.writeline("</head>"); w.writeline("<body>"); w.writeline("<div>"); w.writeline("<img src='images/" + imagename + "' alt=" + fluimage.filename + " />"); w.writeline("</br>"); w.writeline("<div>"); w.writeline(txtdescription.text); w.writeline("</div>"); w.writeline("</div>"); w.writeline("</body></html>"); w.dispose(); } fs.dispose(); } } }

// encription && decription // public class encryptiondecryption {

public encryptiondecryption() { } private static string keystring = "552f79d3-1f36-48ab-934c-4629c2274d43"; private const string strtamperproofkey = "astkvsnanvpi"; public static string tamperproofstringencode(string strvalue, string strkey) { system.security.cryptography.mactripledes mac3des = new system.security.cryptography.mactripledes(); system.security.cryptography.md5cryptoserviceprovider md5 = new system.security.cryptography.md5cryptoserviceprovider(); mac3des.key = md5.computehash(system.text.encoding.utf8.getbytes(strkey)); homecoming system.convert.tobase64string(system.text.encoding.utf8.getbytes(strvalue)) + system.convert.tochar("-") + system.convert.tobase64string(mac3des.computehash(system.text.encoding.utf8.getbytes(strvalue))); } public static string tamperproofstringdecode(string strvalue, string strkey) { string strdatavalue = ""; string strcalchash = ""; strvalue = strvalue.trim(); strvalue = strvalue.replace(" ", "+"); system.security.cryptography.mactripledes mac3des = new system.security.cryptography.mactripledes(); system.security.cryptography.md5cryptoserviceprovider md5 = new system.security.cryptography.md5cryptoserviceprovider(); mac3des.key = md5.computehash(system.text.encoding.utf8.getbytes(strkey)); seek { strdatavalue = system.text.encoding.utf8.getstring(system.convert.frombase64string(strvalue.split(system.convert.tochar("-"))[0])); strcalchash = system.text.encoding.utf8.getstring(mac3des.computehash(system.text.encoding.utf8.getbytes(strdatavalue))); } grab { throw new argumentexception("invalid tamperproofstring"); } homecoming strdatavalue; } public static string getencrypt(string value) { if (new handlenull().checknull<string>(value).trim().length == 0) homecoming value; homecoming tamperproofstringencode(value, strtamperproofkey); } public static string getdecrypt(string value) { if (new handlenull().checknull<string>(value).trim().length == 0) homecoming value; homecoming tamperproofstringdecode(value, strtamperproofkey); }

}

change line's code seek w.writeline("");

asp.net

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -