Search code examples
c#javascriptasp.netvisual-studio-2010master-pages

Embedding javascript tag in child page


I have a JavaScript code which links to survey poll page. When I am embedding the JavaScript code in normal aspx page (without master page), I am getting the survey normally without any issues, but when I am embedding the same code in page which uses master page, I am getting blank page.

This way doesn't work: http://gyazo.com/27f38b5b04897cf0b17747eab05cf746

This way works: http://gyazo.com/c69d3b95afe4a0070cd09834e479a97f

Update

Using <script src='<%=ResolveClientUrl("~/Survey/xlaabsolute.asp?p=1")%>' type="text/javascript" /> renders the poll correctly but the button for voting doesn't do any postback http://gyazo.com/b39fcaa8de3438c8c2a625e3816ba4be.

I can see the content http://gyazo.com/b39fcaa8de3438c8c2a625e3816ba4be


Solution

  • Chances are it's how the script is referenced.

    You're using a relative position in your src attribute which could potentially change if it's not in a location that allows Survery/... to be found. Maybe change it to /Survey/... so it always locates the file based on the root path and not where the document currently resides?

    You can also make your script tag runat="Server" and reference the script using traditional ASP relative links: src="~/Survey/..." so it resolves correctly.