hi,
i am taken one master page and 4 child pages i am write a javascript function for childpages 1 and 2. and childpages 3 and 4 not contain any javascript code. i am providing linkbuttons in master page for navigate childpages.
i am write the javascript function name is charscheck() it check the characters of textbox. and this function name is write in body tag of master page. i.e., .
my problem is when i click linkbuttons of childpages 1 and 2 , its redirect to that page, its working. but i am click linkbuttons of childpages 3 and4 it display a script error i.e., "Microsoft JScript runtime error: Object expected" .
(it tells in that childpages 3 and 4 not contain the javascript function) . if i write javascript function for all pages then that time this error message is not displayed. but in our project javascript is use only childpages 1 and 2.
How to solve this problem. my aim is if i am going childpage 3 and 4 it directly redirects not to display javascript error message.how todo this,please give a solution.
Thanks.
Loading
DRISHTYPosted May 18, 2010, 9:39 AM
If you want that your javascript function should be called on loading of Child page 1 and 2 only.
Then you can write following code on page load event of childPage1 and childpage2.
Page.RegisterStartupScript("SetFocus", "")
Remove : onload="charscheck();" from body tag.
ajay rajuPosted May 19, 2010, 4:54 AM
DRISHTYPosted May 18, 2010, 9:33 AM
Write your javascript function in head tag of master page. Then it will be available for your all child pages.
Thanks.