CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 12/6/2007 8:27:43 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 7 Views: 266 Favorited: 0 Favorite
8 Items, 1 Pages 1 |< << Go >> >|
mohamed hassan
Asp.Net User
insert javaScript file in master page12/6/2007 8:27:43 PM

0

Hello all,

any idea about how to insert the js file into master page, and create the content page based on the master page will also be able to see the menus. Thanks

Right now, i am having problem to show the menu in the master page and the content page.

my code is

protected void Page_Load(object sender, EventArgs e)

{

string strScript;

strScript = ".\\menu.js";

Page.ClientScript.RegisterClientScriptInclude("testFileCode", strScript);

 

}



thanks in advance

avci
Asp.Net User
Re: insert javaScript file in master page12/6/2007 8:33:59 PM

0

 in master page;

Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "testFileCode", this.ResolveClientUrl("~/menu.js"));


Click ?Mark as Answer? on the post when it helped.

mohamed hassan
Asp.Net User
Re: insert javaScript file in master page12/6/2007 8:48:58 PM

0

thanks but

Still not working the menu still no appear  Sad
avci
Asp.Net User
Re: insert javaScript file in master page12/6/2007 9:52:31 PM

0

put this method on your file.

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "testFileCode", this.ResolveClientUrl("~/menu.js"));
    }


Click ?Mark as Answer? on the post when it helped.

mohamed hassan
Asp.Net User
Re: insert javaScript file in master page12/6/2007 10:34:45 PM

0

 

still not working can you give me an example working correctly with you

thanks

avci
Asp.Net User
Re: insert javaScript file in master page12/6/2007 10:45:31 PM

0

I have a class in which i registered javascript and masterpage inherits from this class. First, you must be sure that your javascript is working, second your javascript is not in a folder under the project,right?

 


Click ?Mark as Answer? on the post when it helped.

Amanda Wang - M
Asp.Net User
Re: insert javaScript file in master page12/10/2007 6:12:05 AM

0

Hi,

 

From the code, we can see the path of referencing the js file is  

mohamed hassan:
strScript = ".\\menu.js";
, it is not seemly a correct format for the file path.

You can try to check this thread: http://forums.asp.net/t/1023605.aspx 

Or try to use the below code.

protected void Page_Load(object sender, EventArgs e)
    {
        // Define the name, type and url of the client script on the page.
        String strname = "ButtonClickScript";
        String strurl = "~/JScript.js";
        Type cstype = this.GetType();
        // Get a ClientScriptManager reference from the Page class.
        ClientScriptManager csm = Page.ClientScript;
        // Check to see if the include script exists already.
        if (!csm.IsClientScriptIncludeRegistered(cstype, strname))
        {
            csm.RegisterClientScriptInclude(cstype, strname, ResolveClientUrl(strurl));
        }
        //for the body onload functionality
        string temp = "ShowMenu()";
        HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("Body");
        body.Attributes.Add("onload", temp);
    }

About the ClientScriptManager.RegisterClientScriptInclude Method, you can check this MSDN article: http://msdn2.microsoft.com/en-us/library/kx145dw2.aspx
 Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
AliSufyanButt
Asp.Net User
Re: insert javaScript file in master page12/10/2007 1:47:37 PM

0

Link the javascript by using

<script src="menu.js" language="Javascript"></script>

if the menu creation logic is in the js file then if you place it in a span or a div or a td (means any container)

it will create the menu inside that area

e.g

 <script language="javascript" type="text/javascript" src="includes/javafile.js"></script>

<body onload="CreateMenu('TreeBase');">

<span id="treebase" />

</body>

According to logic, we are creating a tree menu in a span. Much easier way then you were using previously. Above code is a psudo code.


Ali Sufyan Butt
Software Engineer
Electronic Solutions Pvt. Limited
8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Master VISUALLY Dreamweaver CS3 and Flash CS3 Professional Authors: Sherry Kinkoph, Sherry Kinkoph Gunter, Janet Valade, Pages: 665, Published: 2007
AJAX, Rich Internet Applications, and Web Development for Programmers Authors: Harvey M. Deitel, Pages: 991, Published: 2008
QuarkXPress 5 for Macintosh and Windows Authors: Elaine Weinmann, Peter Lourekas, Pages: 498, Published: 2002
The Essential Guide to Dreamweaver CS4 with CSS, Ajax, and PHP Authors: David Powers, Pages: 1000, Published: 2008
Special Edition Using Microsoft Expression Web 2 Authors: Jim Cheshire, Pages: 756, Published: 2008

Web:
Adding Javascript file link in Master Page Adding a referece of Javascript files in Master Pages is a pain. Because the location of Javascript can be in directory, you can simply write this: ...
How to add JavaScript file in MasterPage - ASP.NET Forums As long as MasterPage and WebForm are in the same directory the JavaScript file works but when the directories are different I get ...
js files in ASP .NET master page any idea about how to insert the js file into master page, and create the content page based on the master page will also be able to see the ...
Specifying javascript file path on Master pages I have couple of javascript files that need to be referenced for each content page. So I am trying to put them on Master page. ...
ASP.NET Resources - How to Link Stylesheets from a Master Page One of the dilemmas master pages present is how to link to images, web pages, ... How do I register an external JavaScript file? Or a stylesheet? ...

insert javaScript file in master page - ng.asp-net-forum ... any idea about how to insert the js file into master page, and create the content page based on the master page will also be able to see the ...
The file 'myWeb/MasterPage.master' does not exist. - ng.asp-net ... MasterPage does not exist? message will turn up in no delay. .... insert javaScript file in master page - ng.asp-net-forum ... ng.asp-net . ...
using form.findcontrol in a masterpage - ng.asp-net-forum ... Using the FindControl method on the Page reference means we won?t be searching . .. insert javaScript file in master page - ng.asp-net-forum ...
Masterpage and file upload - form problem - ng.asp-net-forum ... Masterpage and file upload - form problem, > ROOT > NEWSGROUP > Asp.Net Forum ... Cant i have a upload form on a page that uses the masterpage above? ... I was using Form View control to insert-update & show data, and for ADO. ... master page & javascript & asp control ids ยท reference to js file in ...
MasterPage, Javascript, and XHTML : Microsoft JScript runtime ... The bottom line is register (with ClientScriptManager's help) your javascript ( with if the .aspx file uses a MasterPage otherwise put the ...






[treeview] how to set font=bold for root node without child node?

seo and viewstate of master pages

treeview , same code , different behavior

master & content page

master page and content page event handling

problem in using both staticsitemapprovider and web.sitemap

how to get the list of themes?

classic .asp site in content page - can it be done?

panel.defaultbutton, form.defaultbutton and templated buttons inside a detailsview

asp.net 2.0 menu interferes with scrolling div

how to use master with multiple contentplaceholders

regarding master page in asp.net 2.0

seo question about masterpages

setting defaultbutton for panel on a webform that using masterpages

treeview like msdn

multiple site map files

div height issues with screen layout

advanced menu creation

help a newb "update a labels text on a masterpage from a content page" please.

how to access the navigateurl of child of treeview in masterpage to content page?

master page with user control causes master page_load to fire twice!

how do i get master page's controls value into content page!!!

roles in sitemapnode

horizontal menu with fixed width cells?

calling master page method from user control

wizard question

scrolling position of the treeview resets on postback to the server

dynamic loading of masterpage

problem with a page that isn't included in web.sitemap

menu control on master page

   
  Privacy | Contact Us
All Times Are GMT