CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.custom_modules Tags:
Item Type: NewsGroup Date Entered: 4/17/2005 1:44:26 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 38 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
11 Items, 1 Pages 1 |< << Go >> >|
kevin.sheng
Asp.Net User
Convert countdown Timer Html to ASCX4/17/2005 1:44:26 AM

1/1

This is a html page with countdown timer created using Javascript, I would like to convert this to a ascx page for a module. I want to add some more controls to the page as well.

First thing I do is to create a javascript file countdowntimer.js.

Then I need to create a ascx control for a DNN mdoule.

How can I reference asp.net control in the javascript file, such as document.timer.start.value?

How can I start a javascript function when a page is loaded. I tried to use body, but it does not seem to be correct.

Expert help is appreciated.

 

Thanks

 

<html>
<head>
<script>
<!-- Begin
var up,down;var min1,sec1;var cmin1,csec1,cmin2,csec2;
function Minutes(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(0,i));
}
function Seconds(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(i+1,data.length));
}
function Display(min,sec) {
var disp;
if(min<=9) disp=" 0";
else disp=" ";
disp+=min+":";
if(sec<=9) disp+="0"+sec;
else disp+=sec;
return(disp);
}
function CountDown() {
cmin2=1*Minutes(document.timer.start.value);
csec2=0+Seconds(document.timer.start.value);
DownRepeat();
}
function DownRepeat() {
csec2--;
if(csec2==-1) {
csec2=59; cmin2--;
}
document.getElementById('display').innerHTML=Display(cmin2,csec2);

if((cmin2==0)&&(csec2==0)) {
window.close();
}
else down=setTimeout("DownRepeat()",1000);
}
function remote(url) {
window.opener.location=url
window.close();
}
DownRepeat();
// End -->
</script>
</head>
<body onLoad="CountDown()">
<form name="timer" align="center">
<input type="hidden" name="start" value="7:00"><p><span id="display"></span>
</form>
</body>
</html>


Kevin Sheng
ErikVB
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/17/2005 10:42:12 AM

0/0

I would suggest some reading up on the client api (there are some client api related documents in the documentation folder) ... The client api offers some function to communicate between client and server ...

Coffee [C]cheers,

erik


Erik van Ballegoij, The Netherlands














amoywolf
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/17/2005 5:16:38 PM

0/0

1. for 2nd question, you can use a script at the end of .ascx file as following:

<script language="javascript" for="window" event="onload">

CountDown();

</script>

2. for 1st question, I think your script should work, or you can use a parameter in CountDown, as following:

var timerstart="7:00";

CountDown(timerstart);

kevin.sheng
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/17/2005 5:58:41 PM

0/0

I cannot make a javascript to run like onload="thisisjstorun.js" using ascx control in a mdoule.

I figured out how to make code behind code of asp.net talk to javascript function, but get stuck with <body onload="thisisjstorun.js"> when implementing DNN module.

Expert help is appreciated.


Kevin Sheng
kevin.sheng
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/17/2005 10:36:58 PM

0/0

Thanks for the help. i appreciate the following idea.

<script language="javascript" for="window" event="onload">

CountDown();

</script>

How can I pass a parameters to the CountDown(); function if I put it at the end of ASCX file? Thanks/Kevin

 


Kevin Sheng
PScarlett
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/18/2005 1:39:34 AM

0/0

You may want to take a look at T-minus (as in T-minus and counting...)  on http://www.tz3p9v.ca  This is a count down timer that I wrote that allows you to display the time until an associated event.

I use a Javascript to perform the countdown display.. Several things to consider, such as allowing several countdown modules on the same page - this means loading the script once per page, and loading some sort of array that can be processed correctly for each module on the page.

Paul.


Paul Scarlett - Ontario, Canada
www.tressleworks.ca
www.tz3p9v.ca
amoywolf
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/18/2005 2:46:19 AM

0/0

in the function definition in .js file, add parameter as following:

function CountDown(p1) {
cmin2=1*Minutes(p1);
csec2=0+Seconds(p1);
DownRepeat();
}

in the caller, as following:

<script language="javascript" for="window" event="onload">

CountDown("7:00");

</script>

tommy

ErikVB
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/18/2005 4:52:37 AM

0/0

Like i said .... take a look at the dnn client api documentation... the client api includes a function to add calls to the body.onload event:

ClientAPI.AddBodyOnloadEventHandler(Page, "yourJSFunction();")

 

cheers,

erik


Erik van Ballegoij, The Netherlands














kevin.sheng
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/19/2005 2:18:21 AM

0/0

DotNetNuke.UI.Utilities.DNNClientAPI.AddBodyOnloadEventHandler(Me.Page, "CountDown('" & txtTime.ClientID & "','" & txtRemaining.ClientID & "');")

This does not start the CountDown function, but if I click a button, which is defined as

cmdStartCourse.Attributes.Add("OnClick", "CountDown('" & txtTime.ClientID & "','" & txtRemaining.ClientID & "'); return false;")

this works fine.

and I do no t want to click the button, how can I make AddBodyOnloadEventHandler work?

 

Thanks for help.


Kevin Sheng
PScarlett
Asp.Net User
Re: Convert countdown Timer Html to ASCX4/19/2005 8:51:28 PM

0/0

Kevin,

Here is what I do for T-minus.

IlLoad a script once per page.  The script defines defines an empty array and a set of  function that processes any data found in that array. The script also executes "window.onload=start_countdown" when loaded.  The start_countdown function causes the main script to run.  As a last step in the main script (countdown), a call is made to run the main script again in 1 second via "setTimeout("countdown()", 1000).

Now as each T-Minus module is loaded on the page, the module executes one of the javascript functions to add data into the array define above.  On the next execution of the main script, data is found and processed.  As more modules are present, more data is added to the array and the main script processes all the data found in the script.

To load the script I using "Page.RegisterClientScriptBlock" and pass the code to load the script. <script ...  > 

The trick is getting a function to execute every so often looking for work to do.... then supply the work.  This will be as if the user pressed a button.

If you download T-minus you can see the script.... I removed the spaces and new line to speed up loading (60% reduction in size) so you will need to dig a little... if you want the uncompressed version let me know via E-mail link below.

Paul.


Paul Scarlett - Ontario, Canada
www.tressleworks.ca
www.tz3p9v.ca
kevin.sheng
Asp.Net User
Re: Convert countdown Timer Html to ASCX5/1/2005 1:08:38 AM

0/0

Yes, thanks very much indeed for the help. I got it fixed.
Kevin Sheng
11 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Convert countdown Timer Html to ASCX - ASP.NET Forums This is a html page with countdown timer created using Javascript, I would like to convert this to a ascx page for a module. ...
Building an ASP.net Website and Assigning Roles on GoDaddy.com ... convert countdown timer html to ascx · collection was modified; enumeration operation may not execute. error installing store ...
Best way to compile ascx controls | Tech Off | Channel 9 I have a web app with a lot of ascx controls in it that I need to refactor quickly so I can reuse them in other projects.As I do not have time to to rewrite ...
Experts Exchange - Time Tested Solutions print Selected value from Select in HTML. if i have this in my ascx




Search This Site:










cannot upload files to isp

making a menu choice appear selected after choosing?

visual studio-project types

help!! how to use role-based authentuation

error on edit pages

problem with controls registered in web.config

bugs / feature ?

error creating edit control <asp:hyperlink navigateurl='

problem with viewstate when having a label in the master page and the rest of the form in the content page

confirm password change dialog???

is microsoft kidding with this thing?

how to get personal starter kit to work with sql 2005 beta?

disable the use of back button on browser - the solution

wikinews - how to get the feed into dnn 3.0.13

how to compile

aspnetmenu tabstrip - silver?

authorization verbs

where to save acounts?

intermittent error

explain wizard steps in member_register.aspx

simple image/link module

trying to add a verb menu to webpartverbcollection

need a way to expire cache of credentials and event required to trigger this when browser exits

msdn subscription changes for vs2005 on msdn web site

suggestion for recent solpartmenu problems

sqldataadapter & sqlcommand

reconfigure a component to work inside ibs c#

how to set 'group name' for radio buttons in child gridview

smr initials - who is that?

left align text in terms and privacy?

 
All Times Are GMT