开发者

retrieving a value from a jquery countdown/up back to the controller in asp.net mvc2

I am trying to measure the time the user spends on a page before clicking submit. I am using the jquery countdown in a hidden div.

I want that when the user clicks submit, the value of the countdown will return back to the controller, what is the correct way of doing this?

in my form I have a hidden input:

and the script:

$(function () {
 $('#defaultCountdown').countdown({ since: 0,onTick: setSeconds, format: 'S'});
});

function setSeconds() { $('response').text($('#defaultCountdown').countdown('getTimes')[6]); }

in the controller I use

ed.responseTime = Int32.Parse(collection["response"]);

I tried to swap text with html and it 开发者_运维知识库doesn't work either

is it because the page is model based and the hidden input is not in the model?


This may not be the entire answer, but I believe you need to use .val() to set the hidden fields value. Also $('response') doesn't look like a correct selector. Is 'response' the id? If so use $('#response').

For retrieving the value on the server-side, try using Request["theName"] or just add it as a second parameter in your method signature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜