1

I have a user control that i have registered to an aspx page. Now from the aspx page, i am trying to access one of the registered usercontrol's hiddenfield value in my aspx page using javacript using the below code:

tst = document.getElementById('control1$hdnField').value;

I looked into the page's trace, and i could see 'control1$hdnField'. Then why i am not getting its value in my aspx page. I have also ensured that the hidden field exits on the user control and has a default value set.

Please help.

1 Answer 1

2

I think what you have is the name of the field, what you need is the ID of the field, which would have a _ instead of $ as a delimiter, like this:

var tst = document.getElementById('control1_hdnField').value;

Since your hidden <input>, I'm pretty sure looks like this:

<input type="hidden" name="control1$hdnField" id="control1_hdnField" value="val" />
Sign up to request clarification or add additional context in comments.

7 Comments

Tried this as well. But i am still getting 'Object Required' error.
No. I am using -- <asp:HiddenField ID="hdnField" runat="server" Value="Some Value" />
@flopdix - that's what it looks like in your markup...but when it gets rendered to the client the IDs get mangled a bit, prepending the naming container's it's in...unless you're using .Net 4, can you post what your rendered input looks like?
Ok. When i did View Source to my aspx page, i dont see hdnField in the markup. Is that expected? Because in the page trace, i am able to see Control1$hdnField.
No this script is in the aspx page. I am appending Control1/2/3 in the next iteration, so i wont have duplicate ids. I am still stuck, not getting, any ideas?
|

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.