Reputation: 477
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.
Upvotes: 0
Views: 89
Reputation: 477
It was the stupid missing semicolon.
I apologized for wasting everyone's time.
Upvotes: 0
Reputation: 19872
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.
Upvotes: 1
Reputation: 2991
Have you tried:
var hid = "<%= HidingField.ClientID %>";
making sure that "HidingField" is the ID of the server control?
Upvotes: 0