Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have code lines like this

    public double bl = 0;
    browser1.EvaluateScriptAsync("document.querySelector('.amount').value=('#<%= bl%>');");

the class with

    .amount

gets updated with

    #<%= bl%>

but when I put

    "1"

instead of

    '#<%= bl%>'

the field gets updated with

    1

Now, how do I pass the value of the C# variable into the javascript code?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
206 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks for attending people, but this solved me the problem.

    browser1.EvaluateScriptAsync("document.querySelector('.amount').value="+bl+";");

since the code is in c#, I could split the strings for javascript and insert the actual c# variable without any additional demarcations.

thanks to all who tried.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...