I have a question about window's 8 apps Webview Control , is there anyway to use css to manage the look of the webview , i'm using it here to view a returned contents of a feeded html data but as you can see it's striped from all the CSS , so is there anyway that I can manage the CSS for the Webview ?
UPATED : This is the code
void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// this code to populate the web view
// with the content of the selected blog post.
// I'm passing the selected item from the previous items' page
// and then pouplate the web view with the selected item Contents of the feed
if (this.UsingLogicalPageNavigation()) this.InvalidateVisualState();
Selector list = sender as Selector;
FeedItem selectedItem = list.SelectedItem as FeedItem;
if (selectedItem != null)
{
this.contentView.NavigateToString(selectedItem.Contents);
}
else
{
this.contentView.NavigateToString("");
}
}
If you navigate with NavigateToString() - you can put your css inside of the html string that you navigate to. Otherwise - it should just work and we would need more details for what you are actually doing.
Related
I have an aspx page that inherits the IHttpHandler class.
On page load I issued a call to an Impersonation class in which it renders the content under a different username than that currently logged in. But the problem is when impersonated I call a function back on the code behind in the aspx page that needs to access a div tag in order to insert content to it via an object tag and it doesn't find the tag anymore. Any clue as to why? Or to how am I able to build tags from the code behind in such a situation?
The impersonation function I used is based off of : https://www.codeproject.com/Articles/107940/Back-to-Basic-ASP-NET-Runtime-Impersonation.aspx
And this is the function that is called when impersonated within my aspx page:
public void FUNCTION() //This is called from the impersonation function above
{
report = Session[Document];
string url = "http://localhost/PATH" + report.toString();
HtmlGenericControl objReport = new HtmlGenericControl();
objReport.TagName = "object";
objReport.Attributes.Add("data", url);
Control cntrl = Page.FindControl("objReportFrame");
if (cntrl != null)
cntrl.Controls.Add(objReport);
}
I'm trying to navigate within a webpage that has been loaded from a remote server in my WebView control (Cocoa application). I would like to navigate to a particular tag that i can see in the HTML code of that page. The purpose of this all is to show the part of the HTML page that is of my interest at the top of the WebView control.
I know that in HTML code you can navigate by using something like #MIDDLE, #TOP etc. However, is this possible to do from outside of the HTML code using the WebView API?
Thanks for your reply in advance!
I found the answer to my question with the help of an other question (How to scroll HTML page to given anchor using jQuery or Javascript?).
The piece of code below does the trick for me. It searches for HTML elements with attribute: class = "container" in the HTML data that is loaded in the WebView component self.webView.
-(void) scrollMyImportantHTMLPartInView
{
// Get a list of HTML elements that contain attribute class = "container" (eg. <div class "container">)
DOMNodeList *nodeList = [[[self.webView mainFrame] DOMDocument] getElementsByClassName: #"container"];
if( nodeList && nodeList.length >= 1 ) {
// get the first node (class = "container") from the list
DOMNode *domNode = [nodeList item:0];
// Make sure it's a DOM element type
if( domNode.nodeType == DOM_ELEMENT_NODE ) {
// It's now save to cast from DOMNode* to DOMElement*
DOMElement* domElement = (DOMElement*) domNode;
// Scroll begining of HTML node into view
[domElement scrollIntoView: YES];
}
}
}
We are building a website with the Orchard CMS where we have campaign adds.
These adds are linked to pages through tags (not the orchard tag part).
Then we built a custom filter that take these tags into consideration when fetching the campaign adds and display them in a widget.
On some pages there are tags but no campaigns that match these tags. We would like to hide the widget at this point.
One solution is to edit the widget layer every time a new campaign is added. But I would like to have a more solid solution than this.
Summary:
We would like to hide the entire projection widget when the query returns an empty result.
// Madelene
Most of the markup in the widget is rendered by the Widget.Wrapper.cshtml template. What you can do is filter what this wrapper will render based on the content of the widget itself. This way if the widget doesn't render anything, you can decide to hide the title and the other zones. Here is the code doing it:
#using Orchard.ContentManagement;
#using Orchard.Widgets.Models;
#{
var widgetPart = ((IContent)Model.ContentItem).As<WidgetPart>();
var tag = Tag(Model, "article");
var childContent = Display(Model.Child);
}
#if (!String.IsNullOrEmpty(Convert.ToString(childContent))) {
#tag.StartElement
if ((widgetPart.RenderTitle && HasText(widgetPart.Title)) || Model.Header != null) {
<header>
#if ((widgetPart.RenderTitle && HasText(widgetPart.Title))) {
<h1>#widgetPart.Title</h1>
}
#Display(Model.Header)
</header>
}
#childContent
if (Model.Footer != null) {
<footer>
#Display(Model.Footer)
</footer>
}
#tag.EndElement
}
Just create a file named Widget.Wrapper.cshtml in your theme and paste this content. You can check what was the previous content if you want to understand how it's done.
you could override the Projection widget, you can then edit the code for that widget within the cshtml file. This is by far the easiest way.
or
You could create a custom filter that did a check for the dependency and returned no items if that dependency was not met (this is a harder way of doing it)
I'm rather new when it comes to Windows Phone 8 development and I've been toying around with a few things as part of the application I'm developing.
Right now I'm trying to parse information from a website such as the RuneScape 07 High Scores - http://services.runescape.com/m=hiscore_oldschool/hiscorepersonal.ws?user1=zezima
I'm using HTML Agility Pack and I'm able to parse some data (down to Woodcutting), but anything passed that doesn't appear? (Is that down to the size of my ListBox?)
Ideally, I'd like to be able to parse the table information individually rather than in one block like so:
public MainPage()
{
InitializeComponent();
HtmlWeb.LoadAsync("http://services.runescape.com/m=hiscore_oldschool/hiscorepersonal.ws?user1=zezima", DownLoadCompleted);
}
void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
{
if(e.Error == null)
{
HtmlDocument doc = e.Document;
if (doc != null)
{
var result = doc.DocumentNode.SelectNodes("//div[#id='contentHiscores']");
foreach (var htmlNode in result)
{
lBox.Items.Add(htmlNode.InnerText);
}
}
}
But if I try and access an individual table such as this one using
var result = doc.DocumentNode.SelectNodes("//div[#id='contentHiscores']/table/tbody/tr[5]/td[2]");
I get a NullReferenceException.
Is this possible or am I doing something exceptionally wrong?
You probably relied on a developper tools such as FireBug or Chrome, etc... to determine the XPATH for the nodes you're after.
You can' really do this as the XPATH given by such tools correspond to the in memory HTML DOM while the Html Agility Pack only knows about the raw HTML sent back by the server.
What you need to do is look at what's sent back (or just do a view source). You'll see there is no TBODY element for example. So you want to find anything discriminant, and use XPATH axes for example.
Here is a code that seems to work:
// get all TD nodes with ALIGN attribute set to left
foreach (var node in doc.DocumentNode.SelectNodes("//div[#id='contentHiscores']//td[#align='left']"))
{
var item = lBox.Items.Add(node.InnerText.Trim());
// use an 'XPATH axe': get all sibling TD nodes with ALIGN attribute set to 'right'
foreach (var sibling in node.SelectNodes("following-sibling::td[#align='right']"))
{
item.SubItems.Add(sibling.InnerText.Trim());
}
}
I have a requirement where I need to remove or hide the default links displayed in Suite Bar like NewsFeed, SkyDrive, Sites etc. I want to add my own links and use this section as my Menu.
So while adding I want the items to be easily configurable by content editors. They can edit the links that needs to be shown and control the order. No hard coding of links.
If someone can help in this.
Regards,
navish
This can be done by oevrriding Delegate controls that displays these links. The below links will help
http://www.learningsharepoint.com/2013/02/10/addremove-links-in-top-suitebar-skydrivesitesnewsfeed-in-sharepoint-2013/
You should create a custom delegate control that target the SuiteLinksDelegate ControlId.
Add it to a Farm-scoped feature to make the custom delegate control active in the whole farm.
If you do not like hard-coded links you can program against a custom SharePoint list that stores the configurable links.
To Add custom links you can use the approach described here: http://zimmergren.net/technical/sp-2013-some-new-delegatecontrol-additions-to-the-sharepoint-2013-master-pages
If you need to remove some built-in links while keeping others (I had this requirement) you can use code like this:
public partial class SuiteLinksDelegate : MySuiteLinksUserControl
{
protected override void Render(HtmlTextWriter writer)
{
// save for later
var httpwriter = (writer.InnerWriter as HttpWriter);
// hijack the innerwriter
var sb = new StringBuilder();
var sw = new StringWriter(sb);
var tw = new HtmlTextWriter(sw);
writer.InnerWriter = tw;
// call base
base.Render(writer);
// get the html
var currentHtml = sb.ToString();
XElement element = XElement.Parse(currentHtml);
// remove SkyDrive link
var suiteLinkNodes = element.Elements("li").ToArray();
var remainingNodes = suiteLinkNodes.Where(node => !(node.ToString().Contains("ShellDocuments")));
element.ReplaceNodes(remainingNodes);
var modifiedHTML = element.ToString();
// set back the old innerwriter
writer.InnerWriter = httpwriter;
// write delegate control html
httpwriter.Write(modifiedHTML);
}
}
You can use javascript approach to hide this links as described in below link
http://www.tuyrcorp.com/sharepoint-2013-top-links-name-id-and-how-to-hide-them/
you can also add new item in the dropdown using this same javascript as well
Hope this helps
Thanks