0

Below is my JavaScript Function

function HighlightWord(highlightword) {
       alert(highlightword);
}

When I pass value to above function using below code

Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true);

alert displays 'undefined'. What is wrong in this? Thanks.

1 Answer 1

2
Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord(abc)", true); 

means alert the abc variable which I assume you don't have. It should be

Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "HighlightWord('abc')", true);`. 

This will alert "abc" which is what I assume you want to happen.

Sign up to request clarification or add additional context in comments.

Comments

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.