c# - Injected CSS file not applied to injected markup ASP.NET 4 -


hullo everyone, building simple aspx webpage looks word in dictionary (get url query string), injects result in placeholder , formats contents appropriately retrieving css file dictionary website.

apparently can't figure out how solve third point, in fact have tried multiple approaches none seems work.

to precise, have retrieved link right css file , injected page header (tried: page_load, page_init event), query result injected in 'resultpanel' place holder in button_click event handler.

i have included aspx markup followed corresponding codebehind file project uses htmlagilitypack.

<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="multidictionary.default" %>  <!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>     <asp:placeholder runat="server" id="hdr"></asp:placeholder> </head> <body>     <form id="form1" runat="server">     <div>         <h3>             enter url , contents of page</h3>         <asp:textbox id="textboxurl" runat="server" height="20px" width="250px" text="http://www.vandale.nl/opzoeken?pattern=kat&lang=nn">         </asp:textbox>         <asp:button id="button1" runat="server" text="get contents" onclick="button1_click" />         <br />         <asp:literal runat="server" id="resultpanel"></asp:literal>     </div>     </form> </body> </html> 

code behind

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.net; using system.io; using htmlagilitypack; using system.web.ui.htmlcontrols;  namespace multidictionary {     public partial class default : system.web.ui.page     {         private string dictionaryurl = "http://www.vandale.nl";         private ienumerable<htmlnode> csslink;          protected void page_init(object sender, eventargs e)         {          }         protected void page_load(object sender, eventargs e)         {             //your code             string url = textboxurl.text;             var webget = new htmlweb();             var document = webget.load(url);             csslink = (from el in document.documentnode.selectnodes("//link[@type='text/css']")                                               (el.attributes["rel"] != null) && ("stylesheet".equals(el.attributes["rel"].value))                        select el);             if (csslink != null && csslink.count() > 0)             {                 htmllink csslink = new htmllink();                 csslink.href = dictionaryurl + csslink.firstordefault().attributes["href"].value;//"path css";                 csslink.attributes["type"] = "text/css";                 csslink.attributes["media"] = "all";                 hdr.controls.add(csslink);             }         }         protected void button1_click(object sender, eventargs e)         {             string url = textboxurl.text;             var webget = new htmlweb();             var document = webget.load(url);             var definitiediv = el in document.documentnode.descendants()                                (el.attributes["id"] != null) && ("content-area".equals(el.attributes["id"].value))                                select el;             if (definitiediv != null && definitiediv.count() > 0)             {                 resultpanel.text = definitiediv.firstordefault().outerhtml;             }          }     } } 

should question need clarification please not hesitate contact me.

have checked resulting html in browser? expecting stylesheets missing there domain part of url.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -