I have placed a Rich Textbox in SharePoint webpart & on Button click I want to Print the text same as in the format entered by the user which will have certain HTML tags.
For Printing this, I have created an Application Page in my Solution & Placed a Lable on this Page.
On Button Click I want to Pass Textbox value to my Application Page, I have tried the following:
In My webpart, I have tried the following code to pass the values via Query String:
<script>
function OpenDialPrintLetter() {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', showModalPopUpLetter);
}
function showModalPopUpLetter() {
//Set options for Modal PopUp
debugger;
var description = encodeURIComponent('description') + "=" + encodeURIComponent(document.getElementById('<%= txt_description.ClientID %>').innerHTML);
//var description = document.getElementById('<%= txt_description.ClientID %>').innerHTML;
var options = {
//url: '/_layouts/LetterPrint.aspx?description='+description, //Set the url of the page
url: '/_layouts/LetterPrint.aspx?' + description, //Set the url of the page
title: 'Disciplinary Letter', //Set the title for the pop up
allowMaximize: false,
showClose: true,
width: 900,
height: 800
};
//Invoke the modal dialog by passing in the options array variable
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
</script>
<input id="INLETTER" type="button" title="Letter" onclick="OpenDialPrintLetter()" value="Print Letter" />
Following is the code of LetterPrint.aspx page:
<script type="text/javascript">
window.onload = function () {
window.print();
}
</script>
<div>
<asp:Label ID="lblReport" runat="server"></asp:Label>
</div>
</asp:Content>
Following is the CS code of LetterPrint Page which sets the text onto the label on Page Load:
public string description
{
get
{
if (!string.IsNullOrEmpty(Request.QueryString["description"]))
{
return Server.UrlDecode(Request.QueryString["description"]);
//return Request.QueryString["description"];
}
return "";
}
}
protected void Page_Load(object sender, EventArgs e)
{
lblReport.Text = description;
}
When I am using Encode/Decode, it's showing Nothing on the Page,but without Encode/Decode it is passing some HTML in the URL which is useless
How can I pass the value to the page?
Please Help
Thanks
If I don't Use URLEncode, the following message occurs & the page doesn't open:
The webpage at http://abc:22000/_layouts/LetterPrint.aspx?description=<div%20class="ExternalClass46408EB759074C499EAC82BB2B9EE1AD"><div></div></div><div><!DOCTYPE%20html></div><div><html%20lang="en"></div><div><head></div><div> %20<title>Bootstrap%20Example</title></div><div> %20<meta%20charset="utf-8"></div><div> %20<meta%20name="viewport"%20content="width=device-width,%20initial-scale=1"></div><div> %20<link%20rel="stylesheet"%20href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"></div><div> %20<script%20src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script></div><div> %20<script%20src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script></div><div><style></div><div>.table%20{</div><div> %20 %20width:%2085%;</div><div> %20 %20max-width:%20100%;</div><div> %20 %20margin-bottom:%2010px;</div><div>}</div><div>.boddy%20{</div><div>font-size:11px;</div><div>}</div><div>.footer%20{</div><div>font-size:13px;</div><div>}</div><div>.table>tbody>tr>td,%20.table>tbody>tr>th,%20.table>tfoot>tr>td,%20.table>tfoot>tr>th,%20.table>thead>tr>td,%20.table>thead>tr>th%20{</div><div>border-top:0px;</div><div>padding:2px;</div><div>}</div><div></style></div><div></head></div><div><body%20class="boddy"></div><div><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></div><div> %20 %20 %20 %20<div%20class="container"></div><div> %20 %20 %20 %20 %20 <div%20class="row">&l&IsDlg=1 might be temporarily down or it may have moved permanently to a new web address.
Is there any other way to pass such string to the application page without using Query String Parameter?
Please Help
Thanks