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.

A web part or web form control on this Page cannot be displayed or imported. The type could not be found or it is registered as safe error in while deploying visual web part in SharePoint 2013.


Got this error while adding web part to one of the pages in SharePoint. It was all working fine earlier.

 

After much struggle, realized that the LiveVewWebPart.webpart had the incorrect namespace specified.

Correcting it resolved the issue.