1

Trying to set this textbox

<%= Html.TextBoxFor(m => m.IndicationCalculatorNewGroupName, new {propertyName = "IndicationCalculatorNewGroupName", onchange = "UpdateField(this);", dontRegisterNewIndication = true })%>

like this:

$("#IndicationCalculatorNewGroupName").val('-- Enter new Group Name --');

I am accessing it fine using that Id and everything when I do other things like $("#IndicationCalculatorNewGroupName").show(); but not when I try and set it's text.

Thanks!

1
  • Perhaps the onchange event is getting triggered and causing issues. Temporarily remove it to see if that is the cause. Commented Mar 3, 2011 at 21:53

1 Answer 1

2

$('#IndicationCalculatorNewGroupName').val('-- Enter new Group Name --'); is the correct jQuery syntax, so the issue is something else.

Here is a jsfiddle showing this: http://jsfiddle.net/bdL2Q/

Can you provide additional details please?

What is the markup generated by Html.TextBoxFor? What is the exact jQuery code you are trying to run? (Is it as simple as the snippet you posted?)

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

1 Comment

Found the issue. But you get it cuz you knew syntax was correct ;)

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.