mhsueh001 Posted April 27, 2004 Posted April 27, 2004 Ok, I'm not sure this is really and ASP.NET problem, it's more of a Visual Studio Environmental problem. VS keeps changing my "&" to "&" on the html portion of my asp.net pages, and of course this is incorrect. I have to do a find and replace for all the & back to & each time I load up a page and this is getting really annoying. I can't find where in the preferences or options to keep visual studio from doing this. Any help would be greatly appreciated. Thanks. Quote
bungpeng Posted April 27, 2004 Posted April 27, 2004 Why do you want to use "&" rather than "&"? because HTML "&" = "&" display in browser, so you no need to replace it back to "&". The output for both are same = "&" Quote
wessamzeidan Posted April 27, 2004 Posted April 27, 2004 I had that same problem. So what I did was edit the aspx file using Dreamweaver, not vs.net Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
bungpeng Posted April 27, 2004 Posted April 27, 2004 I still don't understand what is your problem actually, VS.NET work great for me Quote
wessamzeidan Posted April 27, 2004 Posted April 27, 2004 I think the problem occurs when you try to paste a piece of vb code in an asp page when the page is in design view, vs.net will consider it as html code and will change the & to &. Now even if you change to html view and change the & to &, vs.net will change it back to &.........strange Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
mhsueh001 Posted April 27, 2004 Author Posted April 27, 2004 This is indeed the problem I think the problem occurs when you try to paste a piece of vb code in an asp page when the page is in design view' date=' vs.net will consider it as html code and will change the & to &. Now even if you change to html view and change the & to &, vs.net will change it back to &.........strange[/quote'] As described by wessamzeidan, this is the problem. For example I want to link to my style sheet in my Application path's root directory: I type: <link rel="stylesheet" href='<%= Request.ApplicationPath & "/MyStyles.css" %>' type="text/css" > If I run it immediately it works. However the minute I begin to edit something on the aspx page it changes the line above to: <link rel="stylesheet" href='<%= Request.ApplicationPath & "/MyStyles.css" %>' type="text/css" > This gives me an error because it doesn't recognize & as proper vb coding. It does this EVERY time I modify the page and I have to go in and remodify it. It's getting really annoying. Any idea where I can turn off the checking for this. Please don't tell me it's the intellisense cuz I don't want to turn that off. ;) Quote
Arch4ngel Posted April 27, 2004 Posted April 27, 2004 Change to C#. Concatenation with C# are made with + LOL. :p Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Arch4ngel Posted April 27, 2004 Posted April 27, 2004 Change the auto-formating Goto Tools/Options.../ Text Editor / "HTML/XML" / Format And then remove the autoformating checkbox (2 first). Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
akiaz Posted April 27, 2004 Posted April 27, 2004 I've tried to duplicate that problem and cannot. Every time I paste or edit, the & stays as an & and never changes to an &. Therefore, my settings must be different from yours that's causing this. I have intellisense turned on, so that can't be causing it. My options are as follows: I have the 'Pretty Listing' turned off for VB code but that should only affect your code behind pages. I have the 'Apply Automatic Formatting' for HTML/XML turned off for both 'When saving document' and 'When switching from Design to HTML/XML view'. The HTML Specific and XML Specific options are all enabled (checked). Hopefully that will help, if not then maybe this is something controlled elsewhere? Quote
mhsueh001 Posted April 27, 2004 Author Posted April 27, 2004 Arch4ngel Change the auto-formating Goto Tools/Options.../ Text Editor / "HTML/XML" / Format And then remove the autoformating checkbox (2 first). I did this, but it didn't solve my problem. It's still replacing the & with & Thanks though. Quote
mhsueh001 Posted April 27, 2004 Author Posted April 27, 2004 I've tried to duplicate that problem and cannot. Every time I paste or edit, the & stays as an & and never changes to an &. Therefore, my settings must be different from yours that's causing this. I have intellisense turned on, so that can't be causing it. My options are as follows: I have the 'Pretty Listing' turned off for VB code but that should only affect your code behind pages. I have the 'Apply Automatic Formatting' for HTML/XML turned off for both 'When saving document' and 'When switching from Design to HTML/XML view'. The HTML Specific and XML Specific options are all enabled (checked). Hopefully that will help, if not then maybe this is something controlled elsewhere? It's not a hard problem to duplicate so follow this. Create a new web project with Visual basic.Net Call it the default WebApplication1 or what ever. Go to the WebForm1.aspx that is created and View it in html format (Double Click on WebForm1.aspx) On the bottom of the form designer you see two buttons that allow you to switch between Design view and HTML view. Switch to the HTML view since it default to start up in the Design view. Add this line: <link rel=stylesheet type=text/css href='<% Request.ApplicationPath & "/Styles.css" %>' > Which will link the cascading style sheet to the web page for your usage. I typically add this line between the <HEAD> and </HEAD> tags. For example: <HEAD> <title>WebForm1</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name=vs_defaultClientScript content="JavaScript"> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> <!-- I ADDED THE LINE BELOW --> <link rel=stylesheet type=text/css href='<% Request.ApplicationPath & "/Styles.css" %>' > </HEAD> This allows me to use the cascading style sheet. Now go back go design view for the WebForm1.aspx Simply drag on a Web Forms Label Control. Or make any modification that causes the form to have that little * appear in the name indicating that the page has been modified. Now switch back to the HTML view of the page and voila the original line now says <link rel=stylesheet type=text/css href='<% Request.ApplicationPath & "/Styles.css" %>' \> Pissing me off... Of course they say better Pissed off than pissed on. Quote
akiaz Posted April 27, 2004 Posted April 27, 2004 OK, I followed your method and duplicated what you said. Well, i never use the design view is VS cause I think it is a true piece of garbage. The solution is to code your page only in HTML view. Not an elegant solution though, sorry. It appears that the designer modifies more code than just what is inserted when dropping the label control. I have always noticed that just switching between design mode and HTML view can cause this, which is why I set HTML view as default and never touch the Design button. I am using VS 2002 so I don't know if this is the same with VS 2003. Are you using the new VS version? Quote
wessamzeidan Posted April 27, 2004 Posted April 27, 2004 But there must be a solution for this. I have another similar problem too. Some times, when I edit using html view and switch back to design view, vs.net crashes. When this happens, the only way I can edit my aspx file is by using dreamweaver or some other text editor Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
mhsueh001 Posted April 27, 2004 Author Posted April 27, 2004 Yes, unfortunately I'm use VS 2003 the most recent version that I know of. Any ideas of a work around? Quote
bungpeng Posted April 28, 2004 Posted April 28, 2004 I thought in ASP.NET, mix together HTML code and server side VB code is not recommended? Why not separate it? As what I know, the performance will be better example, In aspx: <Link rel="stylesheet" type="text/css" id="myID" runat="server" /> 'In Class Level Protected WithEvents myID As HtmlGenericControl 'In Event (Page_Load) myID.Attributes.Add("href") = "default.css" Quote
wessamzeidan Posted April 28, 2004 Posted April 28, 2004 Sometimes you're forced to write vb code in html, mostly when you use template columns in a datagrid and datalist Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
georgepatotk Posted April 28, 2004 Posted April 28, 2004 I GOT THE SAME PROBLEM TOO..... maybe got to call bill up and ask him.. Quote George C.K. Low
mhsueh001 Posted April 28, 2004 Author Posted April 28, 2004 I thought in ASP.NET, mix together HTML code and server side VB code is not recommended? Why not separate it? As what I know, the performance will be better example, In aspx: <Link rel="stylesheet" type="text/css" id="myID" runat="server" /> 'In Class Level Protected WithEvents myID As HtmlGenericControl 'In Event (Page_Load) myID.Attributes.Add("href") = "default.css" As a note: The syntax in your Page_Load should be myID.Attributes.Add("href", "default.css") 'At least that's the syntax in VB.NET Sweet, that works well and keeps me from that headache. I no longer see the style sheet being applied instantly as I work in Design View, which I liked, but I'd rather work this way than have to remember to change the & back to & each time. Thanks for your solution! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.