c# add page to onenote from template - c#

New to OneNote development. I have an app that I want to add a new page based on the template that is the default in this section of my notebook.
I want to take some text from a textbox and name the generated new page to that text. I don't need to do anything else with the page from the app Any ideas would be much appreciated.

You can use the Onenote API to programmatically recall the template page's content as html See http://dev.onenote.com/docs#/reference/get-pages/v10menotespagesidcontentincludeids on how to do this.
Once you have the template's html, you can make the title tag with the title you get from your web form . eg: my title and make a POST request to the section. See http://dev.onenote.com/docs#/reference/post-pages/v10menotessectionsidpages
That should take care of it.

Related

Insert html title and meta description server side in ASP.NET?

I am using IIS 7 and ASP.NET.
What I would like to do is being able to server side change the title and the meta description of my index.html file, before it is shown in a webbrowser.
<title>Replace with text here on server</title>
<meta name="description" content="Replace with text here on server">
I understand I can create either a http handler, http module or http filter in ASP.NET to do this hook up on the request. I found examples of appending html this way, but none showing how to replace/insert text for existing html.
I imagine pseudo code could look like this:
Process_Request(file, content)
{
if (file == index.html)
{
content.replace("<title>xxx</title>", "<title>This is what I want title to be</title>"));
...same replace for description
}
return content to client;
}
How can I do this?
SOLUTION
I created a content parser module based on the code and example from this article. Unfortunately the author left out the part about adding the module to web.config, so you should remember to implement that part yourself.
What I did was to put the title and description change into the Write method based on the url segment and a database lookup.
Server side, you can set the Page.Title in the Master page's Page_Load event to change the title.
Also server side, use the HtmlMeta class to change meta properties as described here: https://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlmeta(v=vs.110).aspx
In Angular you can use the setTitle method of the Title service in Browser platform: https://angular.io/guide/set-document-title
Also Angular Browser platform, Use the Meta service addTag method to manipulate meta tags in Angular: https://angular.io/api/platform-browser/Meta

How to open a webview in reading view ? UWP

I have a FeedReader app and I would like my pages open in reading view ( feature from IE 11 , EDGE ) .as an example The news app in windows 10 uses this feature and all news descriptions are in reading view . is it possible ?
Reading View example (Screenshot) :
https://social.msdn.microsoft.com/Forums/getfile/733596
News app reading view example (Screenshot) :
https://social.msdn.microsoft.com/Forums/getfile/733599
Thanks in advance .
In these cases the content of the web page is extracted and shown with custom styling.
To get the same result you can use something like DIFFBOT (which I think is used in the News app) or Embedly which is cheaper, and get the content parsed and returned nice and structured. After that you'll have to style it yourself.
You can style it by "converting" it from HTML and show it in a TextBlock, or you can show it in a WebView.
EDIT:
You can use something like HtmlUtilities.ConvertToText to get the text from the HTML. I think you can convert one section at a time, that way you can style headers and such.

ASP.net Passing Links from Page to Page

I am trying to display a page into an IFrame.
The IFrame is displayed into a fancyBox overlay popup.
I have a list with the http links (gets compiled at runtime and it constantly changes).
Using a global variable I can access the list with the links.
But the http link in the list must match the link I have clicked.
If I can even get the link which I have clicked it will also be enough (the link brings up a fancyBox popup so it doesn't actually bring up a new page so to speak)
How to do that?
You have to write some tricky code to achieve this, main goal is to edit the dynamically added page content by adding wrapper tag (with onclick event) around all the links, writing javascript to be called using that wrapper to findout which link has been clicked,
You can try this by doing following steps
1) Get the content of IFrame , using the following JQuery code you can get the content of IFrame
var $currentIFrame = $('#myIFrame');
var content = $currentIFrame.contents();
2) Now manupulate these content by finding all the links inside that page and wrapping them with a tag that should have onclick event e.g. span , you have to write some javascript function to fire on a link if user clicks it.
see the following link for how to manipulate content
Get all links inside iframe and add blank target attribute

Modifying rich content on home page programmatically

I am provisioning site collections programmatically in SP2010. The process is working fine but I need to be able to customize some text on the home page that is contained in rich text (not in a web part). Is there a way to grab that HTML code and modify it from code? For instance, embedded within the home page, I have a title and a paragraph of text. I'd like to customize the title based on one of the input values provided from the provisioning request. Is it possible to do this? Any suggestions would be appreciated!
You can access the content area as follows:
PublishingWeb pw = null;
//"web" is your SPWeb, didn't include using statement for your SPSite/SPWeb in this sample
if (PublishingWeb.IsPublishingWeb(web))
{
pw = PublishingWeb.GetPublishingWeb(web);
}
//todo: add some handling here for if web is not a publishingWeb
//assuming your home page is the default, if not - get the correct page here
SPFile defaultpage = pw.DefaultPage;
if (!(defaultpage.CheckOutType == SPFile.SPCheckOutType.None))
{
//programatically creating this stuff, so cancel any unexpected checkouts
defaultpage.UndoCheckOut();
}
defaultpage.CheckOut();
//Field you want to add HTML in (Alternatively, retreive existing data and modify the HTML)
defaultpage.ListItemAllFields["PublishingPageContent"] = "string of HTML";
defaultpage.ListItemAllFields.Update();
defaultpage.CheckIn("My Comment");

ASP.NET Which HTML editor can do everything I want?

I have tried to use the standard AJAX HTMLeditor from here (http://www.asp.net/ajaxlibrary/act.ashx) and I have try to work with the FCKEditor (from http://ckeditor.com/)
But both don't do everything. I call the AJAX standard control A and the FCKeditor F.
With the A editor it is impossible to get your HTML text in the HTML content. You can only get it in the Design content. (this next code doesn't do the job: string htmlContentStr = Editor1.Content).
With F it is possible to get it in the HTML content (it does this by default), but to get your changes back in HTML is impossible. (this next code doesn't do the job: string htmlContentStr = FCKeditor1.Value).
So what I need is a HTML editor that is possible to put HTML text in HTML content, a user can make changes in the designcontent and after the changes 're make it must be possible to get the HTMLcontent and put it away in a string or database.
Is this possible or do I need a commercial one to get this feature?
If my question isn't clear, please let me know.
Thnx
I've used XStandard quite easily and it let me manipulate the HTML. I didn't bother using it as a control, but just read and wrote (escaped) the HTML where needed into the asp output.

Categories