开发者

Interacting with ASP.NET properties in Javascript

开发者 https://www.devze.com 2023-01-06 13:37 出处:网络
I am try in to get the ClientID of one of my server controls to appear in a Javascript in my aspx page.

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) %>";
doSometh开发者_运维问答ingElse(hid);

Any advice?

Thanks.


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.


Have you tried:

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

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


It was the stupid missing semicolon.

I apologized for wasting everyone's time.

0

精彩评论

暂无评论...
验证码 换一张
取 消