0

The closest I got to using in webpage was as follows:

<script>
$('#title').text(movie.title);
</script>

It works with lets say:

<h1 id="title"></h1>

However I would like it to be used in the value in asp hidden field eg

<asp:HiddenField ID="name" runat="server" Value="title" />

I am new to asp and javascript and jquery so any advice greatly appreciated.

4 Answers 4

1

Try to use:

$("[id$='name']").val(movie.title);
Sign up to request clarification or add additional context in comments.

Comments

1

With jquery:

$('#name').val(movie.title);

OR

$('#<%= name.ClientId %>').val(movie.title)

With javascript

document.getelementid('name').value=movie.title;

Comments

0

You need to use Control.ClientID to get the Client ID of ASP.NET Control. After that you can simply use ID Selector and .val()

Use (jQuery)

$('#<%= name.ClientId %>').val(movie.title);

With Vanilla JS

document.getElementById('<%= name.ClientId %>').value=movie.title;

Comments

0

Try this..You have to set clientidmode property to static..

<asp:HiddenField ID="name" runat="server" Value="title" clientidmode="static"/>

After that set..

document.getelementid('name').value=movie.title;

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.