Visual Studio 2010 Auto-Formatting ASPX maladies - asp.net

Alright. I've done a LOT of searching around, and found many posts that address this issue, but do not actually have any resolutions.
Visual Studio 2010 really likes auto-formatting my code. This is all great and wonderful, when it's actually doing what I tell it to.
Whilst editing an .aspx file, formatting does not work well for me. So I try to place spaces before and after all my closing tags and Format Document (ctrl+k,Ctrl+d or Ctrl+e,d), and it will format it according to the Tag Specific Options... in Text Editor->HTML->Formatting, which I have obsessively set, checked, and double-checked.Apparently the requirement of leading and trailing spaces for formatting was a design decision, although it's lost on me as to why, since most whitespace is ignored in parsing of normal html documents. Whatever, I can deal, I just need to put in a ton of extra spaces, then it will do it right, right? In short: no.
Point being: After I've taken pains to make sure that it is formatting everything the way I have it set to, by putting a ton of extra spaces in my markup and Format Documenting, like so:
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
<div id="Week2Summary" align="right">
Week 2 - Summary
</div>
<br />
<div id="PayPeriod" align="right">
Pay Period- Summary
</div>
</div>
<br />
<asp:Panel ID="pnlTimeModify" runat="server" Visible="False" borderColor="#009900"
Width="100%">
whenever I switch to the designer view, save, or sometimes just look at it wrong, it takes out all of the spaces, reformats, and screws it all up:
</asp:TableCell></asp:TableRow></asp:Table></div><div id="Week2Summary" align="right">
Week 2 - Summary </div><br /><div id="PayPeriod" align="right">
Pay Period- Summary </div></div><br /><asp:Panel ID="pnlTimeModify" runat="server" Visible="False" BorderColor="#009900"
Width="100%">
So, I've installed PowerCommands and Productivity Power Tools, one of whom adds a "format on save" setting that is defaulted to off. Great! Restart, and it seems to work great. Reboot a couple times, and it's doing it again. Now I'm about to blow up the computer and walk out of the office. I'll save the rant for some other place.
In Short: I need to know how to make VS either:
stop formatting automatically whenever it feels like it
stop taking out my spaces that force formatting to work correctly when it does
or stop requiring the extra spaces in the first place
so I can work in peace again. (I'm sure the girls down the hall are getting sick of my periodic screaming.)
What I've tried:
Set formatting settings in Text Editor->HTML->Formatting->Tag Specific Options...
Install PowerCommands and Productivity Power Tools and edit the settings to "prevent" formatting on save
Use extra spaces to force formatting to work properly (which are taken out automatically by VS whenever I save or switch views)
Change the File Extensions options so that .aspx are opened as XML and HTML documents, neither helping at all.
However, it continues to raise my blood pressure. Thanks for any help you can give me. I'm going to go have lunch and try to calm down.

was having the same problem, and I found the answer on Scott Gu's blog.
The solution is to setup the formatting rules in Visual Studio (right click on any tag, click on Formatting and Validation, click on Tag Specific Options)
When press ctrl-k, ctrl-d the document will format as per your settings. If a closing tag does not move to a ne.w line, it's because there is no space between the end tag and what is preceding it. This happens because Visual Studio is being careful to not change how the page is rendered.
For the full blog post checkout Scott Gu's blog post.
http://weblogs.asp.net/scottgu/archive/2006/07/07/Tip_2F00_Trick_3A00_-Custom-formatting-HTML-in-Visual-Web-Developer-and-Visual-Studio-2005.aspx

Related

Wordpress plugin losing formatting on post

I am using the Frontier Post plugin, which does not seem to have active support.
I am running into the problem that when I edit and save a post through the front end, which is one of the features of this plugin, the post somehow loses its formatting. e.g. if I had three paragraphs of text, it becomes one large paragraph, even though when I "inspect" it on chrome, one can clearly see the line breaks.
Why would the text be displaying with no paragraph breaks, even though the inspect code contains them? Perhaps I could fix this with CSS?
Sorry not enough reputation to comment, however I was wondering if you had enough line breaks?
Just having one <br /> would only push the text to the next line, it wouldn't create a separate "paragraph."
Either put in two <br /> tags or split the paragraphs into <p> tags and add css from there (Which is probably the better option)
It turns out this problem is only occurring when I create a post in the back end, and try to edit it in the front end. A post created through the front end does not have this issue.
The problem is due to the fact that Frontier Post has not been updated in a while, and is therefore not compatible with Wordpress Gutenberg. Wordpress Gutenberg (used when creating a post through the back end) uses <!-- wp:paragraph --> to delineate new lines.
Therefore, when a post is edited in the front end, by Frontier Post, it does not recognize <!-- wp:paragraph --> as a new line, .
Since it won't affect the users of my site, I just decided to leave things as they are and make sure that my posts are properly formatted.

Preserving line breaks in TinyMCE source editor

First off, this question has been asked in many forms across the internets but I still haven't found a solution or a definite "not possible" answer.
I'm wondering if I can preserve line breaks in the TinyMCE source editor, Wordpress 4.1.
I currently have the plugin TinyMCE Advanced activated, with the option "Stop removing the <p> and <br /> tags when saving and show them in the Text editor" enabled.
Here are paragraphs that I separated by line breaks. This is how I'd like the text to be preserved:
I then hit 'OK' and re-open the source editor. Here's what's displayed:
At this point, I activate the plugin TinyMCE Advanced, and enable the option "Stop removing the <p> and <br /> tags when saving and show them in the Text editor". This option half-way solves my problem by linebreaking on tags:
However, I still would like a line break between the paragraphs like in the first photo. Does anyone know if this is possible?
Thank you!

'</div' injected in Classic ASP html response, page continues to load

So, this is weird.
We have a 2008 R2 server and Win 7x64 dev workstations running Classic ASP.
One page in the site, at exactly carat position 98301, a </div is being inserted into the source. Notice it's not a fully closing div (</div>) tag. Just </div .
So, all sorts of things are breaking since it moves around, based on other things that modify the page (user permissions, querystring values, etc). But always exactly at position 98301 in the code. And always only on this one page.
I've never seen this before and have no idea where to figure out what's doing it. We have many other pages with hundreds of thousands of characters that are fine. We have shorter pages, too. All the IIS settings are the same for all pages and include a 4Mb response buffer and both static and dynamic compression enabled (which I togged both ways without change). We also have 3 source control branches and this is happening in them all, only on this one page.
We are using 2 Win7x64 dev workstations, 1 Win2008R2 local test server and 1 Win2008R2 prod server, and they all do exactly the same thing.
I've moved around the code some, cut out functions, added new code in there to loop Hello World, and no matter what I do, it always inserts just </div at exactly carat position 98301.
I can't think of anything else to test. All suggestions are welcome! Thank you!
Turns out it was the combination of htmlEncode() and htmlDecode() being on the page, and was only a problem in Chrome (currently v39.x). Firefox and IE worked fine. On our page we had about a 600 line script block, and htmlEncode() and htmlDecode() were close to the top of the block. By moving them to immediately before the </script> tag everything worked and </div was not being injected. While I was not the author of that page, I can see the htmlEncode() and htmlDecode() functions were sourced from here: HTML-encoding lost when attribute read from input field
Additionally, we have both Prototype (1.7.1) and jQuery (1.11.x) loaded, and jQuery loading as var $j = jQuery.noConflict(); before Prototype. Changing return $('<div/>').... to return $j('<div/>').... and even return jQuery('<div/>').... had absolutely no affect on the situation.
I still do not know WHY this was happening, but it has been resolved (for now, anyway) by moving the functions to the bottom of the script tag.

TinyMCE adds <pre> tag when inserting from Word

I have several Drupal 6 sites which use the WYSIWYG module along with TinyMCE. For one of my sites, whenever I use the Paste From Word icon, it adds a < pre > tag with the class "mceItemHidden".
In addition, if the text is long enough, it does this strange thing where I click the "Insert" button in the Paste from Word window, the text appears in the main TinyMCE box, there is a brief pause, and then each paragraph is on a single line, which creates the horizontal scrollbar that is as long as the paragraph.
Has anyone experienced this, and do you have any idea why this is happening? I've tried changing my theme and various WYSIWIG settings and this is still happening.
Pasting from word is an odd thing. I couldn't say for sure but MS seems to tweak it now and then to make it especially difficult to translate (while making sure that it still renders well in IE)
Do you get the same issue in the tinyMCE offical demo, if not you could try upgrading your FCK editor.
Pasting from word to begin with is a pain in the.... It's still a fight for us even with FCKeditor. It was a fight when we used Tiny as well. All that nasty xml and tags were brutal on our CSS.
You might check your drupal filters and the way that tiny sanitizes stuff. I forget where all that is. We used tiny for a while, then switched to FCKeditor. We switched for the image upload support. Much better than tiny. Anywho...
Something must have been corrupt. I just completely removed TinyMCE from the libraries directory, and uninstalled the WYSIWYG module. I reinstalled everything, and things seem to be working (for now).

In-text hyperlinks shown by Internet Explorer without the following space. What can be the reason? YUI?

I've a problem which is most likely some ugly CSS mistake, but I just can't spot the solution (and a few changes I tried did not help).
Some of in-text hyperlinks (not all!) are shown by Internet Explorer without the following space.
here is the example
See the link WatchBot just below the Rationale title (and a few similar links deeper in the article). Firefox, Opera, Chrome, Konqueror - all display it properly: WatchBot can. IE (6.0 but IIRC also 7.0) displays it as **WatchBot***can*.
I am using Yui-reset and yui-base. Is it possible that those libraries cause the problem?
Do you have a script running on, and altering, the content in any way? I say this because the page loads normally initially, but looks as though it undergos some modification later in the loading lifecycle.
If you think reset or base are making this happen try removing them one at a time - I haven't had any experience of this error before however (I usually use the full whack: Reset, Grids, Base and Fonts).
What I did notice however is that the first WatchBot link of the page is simply this:
<p>Have you ever been curious how is
WatchBot
picking the games to observe and save? Here is the explanation.</p>
Where as the second link looks like this:
<span>Due to the FICS limitations </span>
WatchBot<span> can
I have no idea what that second span is doing there - might be something to check up on. (It validated fine however - so there's definitely an closing span somewhere).
I'd say a good place to start would be to but a space after the anchor but before the span, rather than right after the span start tag.
Current state of the things: as steve_c spotted first, and buti-oxa confirmed, it looks like the layout is being spoiled by javascript (and as Ross noted, some extra spans are injected). Thank you all, I missed it.
I am to make experiments and selectively disable those scripts (analytics and google ads) to check whether it helps (my current bet is that maybe I have some HTML error or naming conflict)
Did you try to disable pageTracker? It seems to be the only script on your page, and it looks fine to me in its static form.
EDIT: I wondered what span Ross was talking about - I did not see any. I viewed the source. I just learned that Firefox allows to see both source and generated source (Toos/Web Developer/View Source). Sure enough, generated source has additional span inserted.
Solution: my page was spoiled by the text-link-ads script (which, in fact I activated on English blog by mistake - this is script by adkontekst.wp.pl, Polish firm). After disabling it everything is OK.
Thanks for everybody who pointed me into the right direction.

Resources