hai friends,

i want to access the asp.net variable in the javascript.

ie i want to access the field that was displayed in the asp.net pages will be accessed in javascript.

real problem is,

my project is online examination there i am using duration for the exam which is stored the database, the field is reterived and viewed in one form.

no i want to display the time and set the alert message to the student that ur time is over.

for that i want duration variable to be accessed in javascript.

Got the problem,
plz help me.

in the aspx page do this. Can't remember how to do timers off the top of my head but you should be able to get the point.

<script language=java>
alert('<% writeDuration();%>')

and then in the code behind put this function

public void writeDuration(){
int duration;
// get the duration from the database then




thanks for ur immediate reply. i will check and then tell.

The best way is to use an HTML control instead of Web control
use text filed from HTML tab instead of TextBox in Web Controls Tab
and then right click on it -> run as server control .
then you can use it as a server control (in asp.net) and as an html control in javascript.
You can get it in javascript by document.formname.fieldname
where formname is the form name , and field name is the name of the text filed you created.
and user settimeout(func,1000) which execute the func every 1 second and display the time in the text field through the defintion of the func.

hai friend,

thanks for ur immediate reply, i did it and it's working, but it has one problem i give the duration for the full exam, but it takes the time for one question and after clicking the next button it takes the whole duration and did it again, please reply these message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.