Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
1.43/5 (3 votes)
See more:
I am showing Live time on Master page by java script .Master Page is outside.If i use page outside then live time shows but if the page is inside folder then live time is not showing, i means the path is incorrect .the one line where i am finding span to set Time is------

document.getElementById("clock1").innerHTML = cdate
.Then how to resolve it.
Posted
Comments
DamithSL 14-Jun-14 3:04am    
where your clock1 element located? can you update the question with that html?
Amit Vasi 14-Jun-14 3:07am    
There is table on master page.
<td valign="bottom" align="right">
<div class="date">
<asp:Label ID="lbltim" runat="server" Text="Label">
<span id="clock1"></span>
</div>
</td>
DamithSL 14-Jun-14 3:11am    
where you put the javascript ? I'm asking all these questions because you have not provide enough details to find where is the issue.
Amit Vasi 14-Jun-14 3:13am    
There is another java script file where i am using this span. and give reference of that js to masterpage.
DamithSL 14-Jun-14 3:37am    
if you have clock1 span in master page and correctly add javascript reference to master page this should work. because there is no dependency with content pages. You may have doing something wrong.
if you need to solve this issue, update the question with the minimum code samples which need to recreate the issue.

Hi Amit, considering your question, it seems like you are facing problem when your content page is in a sub-folder and master page is in root folder of the project.

To resolve this issue, please check that MasterPageFile="~/Site1.Master" property is set with a "~" character as follows:
HTML
<![CDATA[<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Test3.WebForm2" %>]]>

Let me know if you have any further query.

- DD
 
Share this answer
 
Assuming you have the span to display time is existing in the master file.
You are trying to set its time from the two separate files which are referencing this master file and are situated at two different locations as mentioned below :-

i) When accessing from the aspx file which is at root and referencing the master file.
ii) accessing from the aspx file which is inside a folder existing at root and referencing the same master file

So here i think the main issue is the core jQuery file and the JavaScript file which holds the code to set the time to the span, whose path differs for both of the aspx files.

So we may go for referencing the JavaScript files as follows :-

HTML
<script src="../Scripts/jquery-2.0.3.js"></script>

Same can be done for other JavaScript files which you are using to refer from master file.

Here the main thing to be marked is the two dots just before the URL for the JavaScript file which signifies the root directory of the project and so as to direct them to refer the file always from root.


Hope this will be of work for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900