0

I have this object @item.DataInicio which is a date and I want it to pass through a javascript function

function checkweek(data) {     
   alert(data);
}

I call the function using a button:

input type"button" onclick="checkweek(@item.DataInicio)"

But it doesn't give the alert.

1 Answer 1

1

When you are passing date parameter to js function, pass it within quoatation '' as shown below

<input type"button" onclick="checkweek('@item.DataInicio')" />
Sign up to request clarification or add additional context in comments.

3 Comments

Yeah, sorry. I'm new here
Can you tell me how do I get the week number from that date? I can't use the date for anything else inside the function.
There is no built in c# method to get the 'day of the week'. you might need to do some manual calculation and then pass it to the js function as another parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.