<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" media="screen" href="/App_Themes/default/rss.xslt"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for Using XDocument.Load() to load an .aspx file (TechOff on Channel 9)</title><atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/forums/techoff/475667-using-xdocumentload-to-load-an-aspx-file/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url><title>Comment Feed for Using XDocument.Load() to load an .aspx file (TechOff on Channel 9)</title><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/</link></image><description>Using XDocument.Load() to load an .aspx file</description><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/</link><language>en-us</language><pubDate>Sun, 05 Jul 2009 01:30:48 GMT</pubDate><lastBuildDate>Sun, 05 Jul 2009 01:30:48 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3608.3122, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;&amp;gt;I'm almost ready to just read the whole thing into a massive string, find the opening and closing tags of the form element, and insert a string of code between it.&amp;nbsp;Which sounds incredibly error-prone and unwieldy.&lt;br /&gt;Actually that was just what I wanted to suggest, if your controls are static/asp.net controls, simple to define, I don't see a better/easier way around. You may also look into the custom project templates (like Silverlight or C++ ones) which have wizards so you'll be able to fit/set more information. The template engine may also do some replacement work for you (like it does with $targetframeworkversion$ attribute) if you figure out how to pass your own custom attribute/value pairs to it.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476900</link><pubDate>Sun, 05 Jul 2009 01:30:48 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476900</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476900/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>&amp;gt;I'm almost ready to just read the whole thing into a massive string, find the opening and closing tags of the form element, and insert a string of code between it.&amp;nbsp;Which sounds incredibly error-prone and unwieldy.Actually that was just what I wanted to suggest, if your controls are&amp;#8230;</evnet:previewtext><dc:creator>Ion Todirel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476900/Trackback.aspx</trackback:ping></item><item><title>Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;This is a total PITA. I thought the same thing Dr. Herbie suggested, and it worked, until I indeed came across some scripts like Ion Todirel warned against.&lt;/p&gt;
&lt;p&gt;I'm already using custom project templates, but they only go so far. I need to modify the ASPX code (as in, add a bunch of controls) for each page generated based on different criteria. Also, each page needs to have a different title, etcetera.&lt;/p&gt;
&lt;p&gt;Any other ideas? I'm almost ready to just read the whole thing into a massive string, find the opening and closing tags of the form element, and insert a string of code between it.&amp;nbsp;Which sounds incredibly error-prone and unwieldy.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476870</link><pubDate>Sat, 04 Jul 2009 13:12:00 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476870</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476870/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>This is a total PITA. I thought the same thing Dr. Herbie suggested, and it worked, until I indeed came across some scripts like Ion Todirel warned against.
I'm already using custom project templates, but they only go so far. I need to modify the ASPX code (as in, add a bunch of controls) for each&amp;#8230;</evnet:previewtext><dc:creator>Bas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476870/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;how about creating a custom project template?&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476624</link><pubDate>Thu, 02 Jul 2009 08:28:25 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476624</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476624/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>how about creating a custom project template?</evnet:previewtext><dc:creator>Ion Todirel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476624/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;Hmm.&amp;nbsp; Sounding more and more like a customer parser is required :(&lt;/p&gt;
&lt;p&gt;Herbie&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476623</link><pubDate>Thu, 02 Jul 2009 08:19:45 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476623</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476623/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Hmm.&amp;nbsp; Sounding more and more like a customer parser is required :(
Herbie</evnet:previewtext><dc:creator>Herbie Smith</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476623/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;aspx files can contain anything (CSS, JavaScript...), and HTML != XHTML, it would require a bit more effort than that&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476622</link><pubDate>Thu, 02 Jul 2009 08:16:52 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476622</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476622/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>aspx files can contain anything (CSS, JavaScript...), and HTML != XHTML, it would require a bit more effort than that</evnet:previewtext><dc:creator>Ion Todirel</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476622/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;How about reading the ASPX file into memory, replacing the '&amp;lt;%' and '%&amp;gt;' with XML-valid markers ('&amp;lt;_percentgoesghere_' and '_percentgoeshere_&amp;gt;' ?), process as XML, then put back the '&amp;lt;%' and '%&amp;gt;'.&lt;/p&gt;
&lt;p&gt;Herbie&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476620</link><pubDate>Thu, 02 Jul 2009 07:49:08 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476620</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476620/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>How about reading the ASPX file into memory, replacing the '&amp;lt;%' and '%&amp;gt;' with XML-valid markers ('&amp;lt;_percentgoesghere_' and '_percentgoeshere_&amp;gt;' ?), process as XML, then put back the '&amp;lt;%' and '%&amp;gt;'.
Herbie
&amp;nbsp;</evnet:previewtext><dc:creator>Herbie Smith</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476620/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;I wouldn't recommend that, because the &amp;lt;% %&amp;gt; tags won't parse with XDocument.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476614</link><pubDate>Thu, 02 Jul 2009 06:44:30 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=476614</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/476614/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I wouldn't recommend that, because the &amp;lt;% %&amp;gt; tags won't parse with XDocument.</evnet:previewtext><dc:creator>Joe Chung</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/476614/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;I'm automating some of our application-building, which involves adding several&amp;nbsp; pages to a project and then modifying them based on certain stuff. Changing the title, adding controls, that sort of stuff. The EnvDTE namespace allows for this sort of stuff with classes, but not&amp;nbsp;ASPX pages, it seems. So instead I figured I'd manipulate the ASPX file through Linq to XML because that's pretty convenient with XML, but now I have to figure out something more unwieldy.&lt;/p&gt;
&lt;p&gt;I might read the aspx into memory, remove the page directive, feed it to an XDocument, manipulate it, write it back and then manually add the page directive back, but that somehow seems error-prone.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475824</link><pubDate>Sat, 27 Jun 2009 15:58:02 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475824</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/475824/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I'm automating some of our application-building, which involves adding several&amp;nbsp; pages to a project and then modifying them based on certain stuff. Changing the title, adding controls, that sort of stuff. The EnvDTE namespace allows for this sort of stuff with classes, but not&amp;nbsp;ASPX pages,&amp;#8230;</evnet:previewtext><dc:creator>Bas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/475824/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;Its not even HTML on his side, the example is using REST and he is loading an XML file from &lt;em&gt;someplace.rss.aspx&lt;/em&gt; RSS is always XML and not HTML or XHTML which is what ASPX is. I'd be interested fo find out what you are tying to do?&lt;/p&gt;
&lt;p&gt;Going the _stevo route would require writing a parser (non trivial) so you'd probably use Sharp Develop or Actipro&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475728</link><pubDate>Fri, 26 Jun 2009 20:37:18 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475728</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/475728/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Its not even HTML on his side, the example is using REST and he is loading an XML file from someplace.rss.aspx RSS is always XML and not HTML or XHTML which is what ASPX is. I'd be interested fo find out what you are tying to do?
Going the _stevo route would require writing a parser (non trivial) so&amp;#8230;</evnet:previewtext><dc:creator>vesuvius</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/475728/Trackback.aspx</trackback:ping></item><item><title>Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;Could perhaps configure/adapt an xml reader so that it can understand / ignore code blocks? not sure how much work that would be..&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475674</link><pubDate>Fri, 26 Jun 2009 13:22:57 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475674</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/475674/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Could perhaps configure/adapt an xml reader so that it can understand / ignore code blocks? not sure how much work that would be..</evnet:previewtext><dc:creator>stevo_</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/475674/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;My bad, I thought he did, but on closer inspection he's loading it via HTTP, so it won't be ASPX by the time it's on his side.&lt;/p&gt;
&lt;p&gt;Anyway, that's annoying. I hoped Linq would be more forgiving about invalid XML.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475669</link><pubDate>Fri, 26 Jun 2009 10:22:30 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475669</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/475669/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>My bad, I thought he did, but on closer inspection he's loading it via HTTP, so it won't be ASPX by the time it's on his side.
Anyway, that's annoying. I hoped Linq would be more forgiving about invalid XML.</evnet:previewtext><dc:creator>Bas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/475669/Trackback.aspx</trackback:ping></item><item><title>Re: Using XDocument.Load() to load an .aspx file</title><description>&lt;p&gt;Where is he loading a .aspx file? I don't see it.&lt;/p&gt;
&lt;p&gt;Fact is that raw aspx files are not valid XML, (not just the&amp;nbsp;lines at the top, but any &amp;lt;% %&amp;gt; block including databinding&amp;nbsp;expressions etc.)&amp;nbsp;so you can't do this without modifying the aspx file first.&lt;/p&gt;</description><comments></comments><link>http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475668</link><pubDate>Fri, 26 Jun 2009 10:15:33 GMT</pubDate><guid isPermaLink="false">http://channel9.msdn.com/forums/TechOff/475667-Using-XDocumentLoad-to-load-an-aspx-file/?CommentID=475668</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel9.msdn.com/475668/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Where is he loading a .aspx file? I don't see it.
Fact is that raw aspx files are not valid XML, (not just the&amp;nbsp;lines at the top, but any &amp;lt;% %&amp;gt; block including databinding&amp;nbsp;expressions etc.)&amp;nbsp;so you can't do this without modifying the aspx file first.</evnet:previewtext><dc:creator>Sven Groot</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel9.msdn.com/475668/Trackback.aspx</trackback:ping></item></channel></rss>