MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

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

Viewed 17913 time(s), 2 post(s) 5/5/2013 7:53:26 PMby hsheldon
hsheldon

hsheldon

5/5/2013 7:53:26 PM
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?
This content has not been rated yet. 
40 Reputation 4 Total posts
khorvat

khorvat

5/6/2013 6:50:49 AM
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
This content has not been rated yet. 
15993 Reputation 2214 Total posts