Created
September 30, 2015 20:21
-
-
Save bjoerntx/f021cd0bd3c817e7f6d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Button1_Click(object sender, EventArgs e) | |
{ | |
// save the document to a string variable | |
var RTFDocument = String.Empty; | |
TextControl1.SaveText(out RTFDocument, | |
TXTextControl.Web.StringStreamType.RichTextFormat); | |
// create a new WebRequest | |
WebRequest request = WebRequest.Create( | |
"http://" + Request.Url.Authority + "/Home/SaveTemplate"); | |
// set the POST data | |
var postData = "documentName=" + TextBox1.Text; | |
postData += "&document=" + RTFDocument; | |
// encode the data as an byte[] array | |
var data = Encoding.ASCII.GetBytes(postData); | |
// set the method, content type and length | |
request.Method = "POST"; | |
request.ContentType = "application/x-www-form-urlencoded"; | |
request.ContentLength = data.Length; | |
// write the data to the request stream | |
using (var stream = request.GetRequestStream()) | |
{ | |
stream.Write(data, 0, data.Length); | |
} | |
// get response from HttpPost method | |
WebResponse response = (HttpWebResponse)request.GetResponse(); | |
// read the data and check for return value "True" | |
var dataStream = response.GetResponseStream(); | |
StreamReader reader = new StreamReader(dataStream); | |
string sReturnValue = reader.ReadToEnd(); | |
if (sReturnValue == "True") | |
lblInfo.Visible = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment