Mono Support Best way to put Javascript into Default.aspx and other pages 

Viewed 18937 time(s), 2 post(s), 5/5/2013 7:53:26 PM - by hsheldon
5/5/2013 7:53:26 PM
40 Reputation 4 Total posts

What's the best way to load custom javascript into a single page?

I wanted to put a simple Javascript in my default.aspx page that will take a random image and place it as a background of a div.  I have the script ready to go but now I'm having trouble understanding where to place it.  I understand I could attach it in the Main.master page but this script is only going to be used in the default page so I didn't want to load it with each page.  

I found a great blog explaining how to Dynamically insert javascript but it's requiring that I can get to the code behind and I don't think I can do that with the default.aspx.  It didn't work when I added the .cs and put a Page_Load method in.

Any suggestions in adding javascript into a page or do I have to load it in the Main.master?

1
5/6/2013 6:50:49 AM
15993 Reputation 2214 Total posts

Hi,

MonoX Default page is one of the demo pages that are present in the MonoX CMS so you can use the code from the GitHub - MonoX-Demo-Pages, also if you put your custom cs file in to the project under the Default.aspx you will need to direct everything to that file and class in order to get it working. So you need to point the following to your newly added cs file and class

//Old
<%@ Page
    Language="C#"
    AutoEventWireup="true"
    MasterPageFile="/MonoX/MasterPages/Default.master"
    Inherits="MonoSoftware.MonoX.Pages.Default"
    Title="MonoX - Portal Framework for ASP.NET"
    Codebehind="Default.aspx.cs" %>
 
//New
<%@ Page
    Language="C#"
    AutoEventWireup="true"
    MasterPageFile="/MonoX/MasterPages/Default.master"
    Inherits="YourNameSpace.Pages.YourDefault"
    Title="MonoX - Portal Framework for ASP.NET"
    Codebehind="YourDefault.aspx.cs" %>
Regards

2
This is a demo site for MonoX. Please visit Mono Software for more info.