Subject: document.getElementById doesnt work in master page
Posted By: vikram_bendre Post Date: 7/26/2006 7:01:16 AM
Hi all,
I have implemented template.master page in default.aspx. There is one situation where in I have to access asp.net controls (dropdown boxes) in Javascript. For which I have used

var MeetingList = document.getElementById("ddlMeeting_Type_Name");

which does not seem to work at all... :(

experts!! is there any way to overcome this problem?

My guessing is since the default.aspx has no document of its own, document.getElementById is not supported...


Vikram
Reply By: Imar Reply Date: 7/26/2006 12:50:04 PM
Hi there,

Take a look at the resulting HTML in the browser. You'll find that .NET has renamed your client ID to something ctrl0_ContentPlaceHolder_ddlMeeting_Type_Name. You'll need to use that ID to reference the control.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply By: vikram_bendre Reply Date: 7/27/2006 1:19:27 AM
WOW!! thanks a lot Imar, I did not even think of it
It is working fine now. thanks again

Vikram
Reply By: radmunson Reply Date: 12/15/2006 3:56:48 AM
It's better to use
document.getElementById("<%= ddlMeeting_Type_Name.ClientID %>");

Go to topic 53491

Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86
Return to index page 85
Return to index page 84
Return to index page 83