![]() |
| ||||||||||
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Javascript Need help with the (primarily) client-side programming language? This is the place. Includes discussion on AJAX (Asynchronous JavaScript and XML). |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
| code: class with javascript::: private ClientScriptManager cs; public LeavingPage(Page page) { this.page = page; WriteJavaScipt(); } private void WriteJavaScipt() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); string scriptString; scriptString = "<script language=JavaScript> " + "string AskMsg; " + "function LeavePage(){" + " if(AskMsg){ " + " ok = confirm(" + "Have you saved your changes? Click OK to Continue to the next page WITHOUT saving." + "\n" + "Click Cancel to return to the current page." + ");" + " if (!ok) " + " {" + " return false;" + " }" + " else" + " { " + " return true; " + " } " + " } " + " else" + " { " + " return true;" + " } " + "} " + "</script> "; cs = this.page.ClientScript; if (!cs.IsClientScriptBlockRegistered(this.GetType(), "clientScript")) cs.RegisterClientScriptBlock(this.GetType(), "scriptString", sb.ToString()); } } ================================================ aspx file: <body> <br /> <form id="form1" runat="server"> <div> <img id= "welPage" alt = "Welcome Page" enableviewstate= "true" src="img/welcome.jpg" usemap ="#tier1"/> <map id="tier1"> <area shape="circle" coords="330, 441, 31" href="javascript: changePage('/mainNav.ascx', '/modules/Books/UserControl1/BookNewEntry.ascx');" alt="Welcome Page" /> </map> <script type="text/javascript" language="javascript"> function changePage(HeaderURL, BodyURL) { if(LeavePage()) { if(BodyURL != '') parent.main.location.href = BodyURL; } parent.header.location.href = HeaderURL; } </script> </div> </form> <div id ="footer"> Copyright © 2009 By OmSolution Inc. All Rights Reserved. </div> </body> ================================================= ChangePage is suppose to load the other pages when the button in the <map> is clicked But when it click the buttton "if(LeavePage())" gives the error "Microsoft JScript runtime error: Object expected" |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Make a Countdown Clock Using JavaScript? | Dr. Phil | Javascript | 0 | 10-19-2009 12:51 AM |
| how to use elseif in javascript to make an iframe visible or hidden when a link is... | jumar j | Javascript | 1 | 10-17-2009 09:09 PM |
| JavaScript: I need to make a calculator for | Richardd B | Javascript | 1 | 05-24-2007 07:05 PM |
| My forum’s administration panel will not load. It is displaying a blank white page | bobleny | Tutorials | 7 | 02-15-2007 06:50 PM |
| The ads make my page unaccessible | Bieb's Page | Web Hosting Support | 6 | 01-24-2006 09:13 PM |