Knockout JS and Razor - How to assign data to Razor variables?

183 views
Skip to first unread message

Ali Aziz

unread,
Apr 21, 2022, 9:25:44 AM4/21/22
to KnockoutJS

I am working with a multi layer web application that uses various web technologies. It interacts with a WebAPI to get the data via Knockout JS.

I will try to narrow the scope of my question to this:

I have a span tag

<span id="title" data-bind="text: FullTitle"></span>

I would like to get the content of that span and assign it to a Razor variable.

I have tried:

@ { 
  var Test = <span id="title" data-bind="text: FullTitle"></span>
}

But this doesn't render the knockout code and it just assigns the full span code to that variable. I just want to get the full title when knockout pulls it into the Test variable.

Note: the span works outside the razor block and displays the full title on the cshtml view.

Any ideas?

Thanks in advance.

Julio Di Egidio

unread,
Apr 21, 2022, 7:58:29 PM4/21/22
to KnockoutJS
You can't do that, not anymore than you can populate a PHP variable from JS: KO is client-side and Razor is server-side, so all you can do, *as usual* (i.e. web programming lesson 1), is post a form to send values back to the server-side.

And this is the last question of this sort I reply to: it's pretty obvious, on side, that this group is under attack by the spammers that be and there is nothing else to add there, but it's also apparent that the maintainers/developers/administrators here have just disappeared and KO's future simply does not exist, as all things good in this indecent and insane world.

HTH and so long.

Julio

Ganesh Nalajala

unread,
Apr 22, 2022, 1:19:04 AM4/22/22
to knock...@googlegroups.com
Guys, can anyone provide the good course for java 

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/knockoutjs/ef604be5-ef23-4001-910c-49a43fd80b9fn%40googlegroups.com.

Julio Di Egidio

unread,
Apr 22, 2022, 11:18:46 PM4/22/22
to KnockoutJS
On Friday, 22 April 2022 at 07:19:04 UTC+2 Ganesh Nalajala wrote:
Guys, can anyone provide the good course for java 

Eat shit and die, you and the whole lot.

*Plonk*

Julio

Ganesh Nalajala

unread,
Apr 22, 2022, 11:20:45 PM4/22/22
to knock...@googlegroups.com
Thanks your suggestion noted
bosdk madarchod mf

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.

Julio Di Egidio

unread,
Apr 22, 2022, 11:24:03 PM4/22/22
to KnockoutJS
On Saturday, 23 April 2022 at 05:20:45 UTC+2 Ganesh Nalajala wrote:
Thanks your suggestion noted
bosdk madarchod mf


Eat shit and die, you and the whole lot of pieces of insane retarded shit.

Get extinguished already.

*Plonk*

Julio

Reply all
Reply to author
Forward
0 new messages