asp.net - How to call javascript function of child page from master page javascript - Stack Overflow

I am writing an ASP.Net application. I am making use of master page in it. I have several child pages wi


I am writing an ASP.Net application. I am making use of master page in it. I have several child pages with me, which consist of some java script functions;
Let's say;

function ChildPageFunction()
{
   //Do something;
}


And master page java script function as;

function MasterPagefunction()
{
   //Need to call ChildPagefunction(); here
}


Now is it possible to call ChildPageFunction() from MasterPageFunction() ?

Please help me if anyone knows how to do this. Thanks in advance.


I am writing an ASP.Net application. I am making use of master page in it. I have several child pages with me, which consist of some java script functions;
Let's say;

function ChildPageFunction()
{
   //Do something;
}


And master page java script function as;

function MasterPagefunction()
{
   //Need to call ChildPagefunction(); here
}


Now is it possible to call ChildPageFunction() from MasterPageFunction() ?

Please help me if anyone knows how to do this. Thanks in advance.

Share Improve this question asked Jul 28, 2010 at 14:27 VJOYVJOY 3,79013 gold badges61 silver badges93 bronze badges 1
  • Since Child Page is from Master Page, you can call childpage function, but be sure that childpage function javascript has been loaded at that moment. – Nazmul Commented Jul 28, 2010 at 14:35
Add a ment  | 

2 Answers 2

Reset to default 2

Yes. Just call ChildPageFunction(); from anywhere on the MasterPage and it will fire.

function MasterPagefunction()
{
   ChildPagefunction(); // Will work fine
}

This works the other way around to, so you can call MasterPageFunction() from your child page and it will also ifre.

This is because, when rendered, all of the master page html and the child page's html are bined, so both pages share the same JavaScript.

The MasterPage is a template that wraps around your Content Page.

It is just javascript, once it is rendered to the browser it has no knowledge of whether it is from the master page or the content page. Just call it normally.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745228750a4617583.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信