Open a popup window while sending post data
Use hidden input elements to pass data to the target URL.
<form action=”<target URL>” method=”POST” target=”_blank”>
<input type=”hidden” name=”Name” value=”Wayne”>
<input type=”submit” value=”Click here to open the window”>
</form>
If you don’t want a button, use CSS to style the submit button to make it look like a hyperlink.
If you use ASP.NET or SharePoint the framework may complain that there should be only one form tag in the page. In that case use Javascript to construct the form on the fly when the link is clicked, then get rid of the form element after the window is open.
function openWindow()
{
var mapForm = document.createElement(“form”);
mapForm.style.display=”none”;
mapForm.target = “Map”;
mapForm.method = “POST”; // or “post” if appropriate
mapForm.action = “http://localhost:55079/Default.aspx”;
var mapInput = document.createElement(“input”);
mapInput.type = “text”;
mapInput.name = “test”;
mapInput.value = “Test Data”;
mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);
map = window.open(“”, “Map”, “status=0,title=0,height=600,width=800”);
if (map) {
mapForm.submit();
}
//delete the form element
mapForm.parentNode.removeChild(mapForm);
}
<a href=”#” onclick=”javascript:openWindow();”>Click here to open window</a>
SharePoint tools
https://spm.codeplex.com/
Clean up orphaned features
http://featureadmin.codeplex.com/
CAML query helper
https://spcamlqueryhelper.codeplex.com/
Search tool:
https://sp2013searchtool.codeplex.com/
RequiredFieldValidator and DropDownList intial value
To solve this, set InitialValue to the required field validator.
If you set a default value to a dropdown list and then disable the dropdown list, the validator will not work correctly. Use a hidden field and use javascript to update it every time the dropdown list’s value is changed, then configure the validator to check the hidden field instead.
Calculated field with hyper link
Parse and send Microsoft JSON Date using Javascript
var date = new Date(parseInt(jsonDateString.substr(6)));
To pass the date back to the ASP.NET server to deserialize, note that JSON.stringify will escape the slashes in the date values causing parse error in the server. To correct this, use the code below
(shttp://stackoverflow.com/questions/11852432/using-net-javascriptserializer-deserialize-with-datetime-from-client)
function customJSONstringify(obj) { return JSON.stringify(obj).replace(//Date/g, "/Date").replace(/)//g, ")/") }
UpdatePanel in Sharepoint
To get it to work, you have to jump through hoops by downloading the SharePoint guidance library thingy as some source code and build it yourself, then deploy it to the GAC of your environment, then add reference to Microsoft.Practice.SPG.AjaxSupport.dll, then use a SafeScriptManager in the usercontrol of your SharePoint webpart.
Maybe it’s better to build the thing using pure HTML and javascript?
Delete workflow auto generated column
Use SharePoint Manager to get the column’s GUID
Then write a console app to remove this column. Multiple column of the same name will break code.
Cannot get workflow to trigger event receiver
Another way is to actually update the list item inside the workflow, usually assigning the same value to the field will work and results in no change to the list item.
Please note that workflow status is set asynchronously, meaning if you make the workflow trigger the event receiver and inside event receiver you read the workflow status, the workflow status is not guaranteed to be correct at the time as the update happens asynchronously.
The best way to read the eventual workflow status is to write it to a list item’s field and read from there in the event receiver.
Disable button on submit using javascript to prevent double clicking
Use this code?
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" ClientIDMode="Static" OnClientClick="disableButton();"/> <asp:Button ID="ButtonDummy" runat="server" Text="Button" ClientIDMode="Static" OnClientClick='return false;' style="display:none;"/>
function disableButton() { $("#Button1").hide(); $("#ButtonDummy").show(); return true; }