-1

I've got a problem with my media queries. On my website I am using a frameset to show a form. This form is created in a asp (classic) file and also has its code in it.

In my first attempt to launch it I had a link to my css stylesheet, though I found out this didn't work since it was cross-server.

So I putted all my css styling directly in my asp code page and my styling is working again. The downside however is that I worked with @media queries in my previous stylesheet, but for some reason when i put my css directly in my asp page (opened with and closed with ) the page gives an error when the @media queries are included. When I leave them out it works fine.

The code + css + html file in a .asp extension.

<!--#include file="tools.asp"-->
<!--#include file="connectionMemo.asp"-->

<HTML>
    <HEAD>
        <style type=text/css>
            <% 
                ' Cannot link css file cross domain
            %>

                @media only screen and (min-width : 1224px)  {

                   .Some style here{ }
                 }


                 @media only screen and (min-width : 1801px)  {

                   .Some other style here{ }
                 }

            </style> 
<TITLE>Ticket aanmaken</TITLE>
    </HEAD>
    <BODY bgcolor="#C0D1E5">
    <h2 align="left"><font face="Verdana, Arial" color="#000080">Ticket aanmaken</font></h2>

~ASP, javascript and html code here for the functionality (to much to all copy paste).

</body>
    </html>

~Some more asp code here

In my first try I included the css stylesheet just like the tools and connection files, this didn't work for obvious reasons (no asp file, not in the header, etc.) Then I just linked the css stylesheet with a href link but because the files were cross domain this didn't work either.

The code above was my last try in which I just pasted the stylesheet directly in the code / functionality page - asp file (so I didn't had the cross domain problem).

This isn't working either though and it seems that the media queries are causing the problem. When I remove the media queries the css is loaded, when I remove only the top media queries the css is also loaded (probably because it loads the first css it encounters and which it can load).

Anyone has an idea how to fix this?

Nicolas
  • 2,277
  • 5
  • 36
  • 82
  • Post some code for a diagnosis, e.g. "This code is working: `BadCode`, and this code is not working: `GoodCode`" – Jamie Barker Feb 27 '15 at 16:34
  • 1
    We're going to need more information if we are going to be able to help you. Can you create a [MCVE](http://stackoverflow.com/help/mcve)? – Dave Feb 27 '15 at 16:35
  • @JamieBarker My apologies, updated the original post with the code! Usually doing this but I thought my explanation was enough, which it isn't of course if you didn't code it yourself;) – Nicolas Mar 02 '15 at 07:50
  • _“a link to my css stylesheet, though I found out this didn't work since it was cross-server”_ – normally stylesheets are not restricted in this way; therefor totally unclear what you are asking here. Abstract your problem from the fact that you are using asp on the server side – the _client_ doesn’t care. – CBroe Mar 02 '15 at 08:01
  • Ah alright, learned something new. Some other programmer told me that was probably the issue/problem. As for the ASP part, better to give more than less information right? – Nicolas Mar 02 '15 at 08:20
  • Could the downvote please be explained, I don't mind being down-voted but some decent explanation about why can help me improve the question, also for in the future. – Nicolas Mar 02 '15 at 08:23
  • Tested the css with a simple @import url("http://myWebsite.com/MyStyle.css"); and indeed, it works. Though it only works when I leave the media queries out.. – Nicolas Mar 02 '15 at 08:29
  • I can speculate that you have an extra `}` or a missing `{`, but only because you haven't actually posted that code for us to see it ;) – Jamie Barker Mar 02 '15 at 09:23

1 Answers1

0

Try to use double @@ symbols. That will escape @ symbol and render @media correctly on client side

Source: https://stackoverflow.com/questions/7027469/media-media-query-and-asp-net-mvc-razor-syntax-clash

Community
  • 1
  • 1
Adrian Enriquez
  • 8,175
  • 7
  • 45
  • 64