0

I am try in to get the ClientID of one of my server controls to appear in a Javascript in my aspx page.

Obviously I am going about it the wrong way, but my intent should be made clear in the following:

doSomethingFirst();
var hid = "<% Response.Write(HidingField.ClientID) %>";
doSomethingElse(hid);

Any advice?

Thanks.

1
  • are you saying that this didn't work? If you put in a Javascript alert and pass it hid after you set it what comes up? Commented Jul 7, 2010 at 20:30

3 Answers 3

1

I'm doing a bit of guessing about your intent, so forgive me if I've guessed wrong, but I think this is what you're looking for:

doSomethingFirst();
var hid = document.getElementById('<%= HidingField.ClientID %>');
doSomethingElse(hid);

I assuming your intent is to get a reference to the DOM element represented by the client id so that you can then do some sort of javascript operation on that element.

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

Comments

0

Have you tried:

var hid = "<%= HidingField.ClientID %>";

making sure that "HidingField" is the ID of the server control?

1 Comment

<% Response.Write(HidingField.ClientID) %>'s kinda equivalent so I guess the OP has already tried this.
0

It was the stupid missing semicolon.

I apologized for wasting everyone's time.

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.