Sharepoint and Javascript document.getElementById

I needed this today! While developing a custom web part for  Sharepoint 2013, I discovered there are some quirks when writing client-side javascript.

http://chris.gg/2010/02/sharepoint-and-getelementbyid/

Instead of:

document.getElementById(“TextBox1”);

Use this:

document.getElementById(“<%=TextBox1.ClientID %>”);

It’s a bit of a pain to have to do this. But, it works.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s