Using clientidmode property to get the id of the control in JavaScript in Visual Web Part

Hi,

In a Visual Web Part we were saving few values in a hidden input field and were retrieving it in the jScript. However the issue we were facing was the id of the control kept changing.

http://therightstuff.de/2006/02/14/Accessing-Controls-In-SharePoint-Web-Parts-Using-JavaScript-On-The-Client-Side.aspx

Here the clientidmode property came to rescue.

<input id=”hiddenobject” type=”hidden” clientidmode=”Static” runat=”server”/>

With the clientidmode set as static the id remains the same.

Hope it helps.


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

Share your thoughts

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